|
13 | 13 |
|
14 | 14 | """This module includes unit tests for the plugin.""" |
15 | 15 |
|
16 | | -from _pytest.config.argparsing import Parser |
17 | | -import pytest |
18 | | -from delayed_assert import expect, assert_expectations |
19 | | -from requests.exceptions import RequestException |
20 | 16 | # noinspection PyUnresolvedReferences |
21 | 17 | from unittest import mock |
22 | 18 |
|
| 19 | +import pytest |
| 20 | +from _pytest.config.argparsing import Parser |
| 21 | +from delayed_assert import expect, assert_expectations |
23 | 22 | from reportportal_client.errors import ResponseError |
| 23 | +from requests.exceptions import RequestException |
24 | 24 |
|
25 | 25 | from pytest_reportportal.config import AgentConfig |
26 | 26 | from pytest_reportportal.plugin import ( |
@@ -258,10 +258,8 @@ def test_pytest_sessionstart(mocked_session): |
258 | 258 | :param mocked_session: pytest fixture |
259 | 259 | """ |
260 | 260 | mocked_session.config.pluginmanager.hasplugin.return_value = True |
261 | | - mocked_session.config._reporter_config = mock.Mock( |
262 | | - spec=AgentConfig(mocked_session.config)) |
| 261 | + mocked_session.config._reporter_config = mock.Mock(spec=AgentConfig(mocked_session.config)) |
263 | 262 | mocked_session.config._reporter_config.rp_launch_attributes = [] |
264 | | - mocked_session.config._reporter_config.rp_launch_id = None |
265 | 263 | mocked_session.config.py_test_service = mock.Mock() |
266 | 264 | pytest_sessionstart(mocked_session) |
267 | 265 | expect(lambda: mocked_session.config.py_test_service.init_service.called) |
@@ -298,22 +296,20 @@ def test_pytest_sessionstart_launch_wait_fail(mocked_log, mocked_session): |
298 | 296 | ) |
299 | 297 |
|
300 | 298 |
|
301 | | -@mock.patch('pytest_reportportal.plugin.is_control', mock.Mock()) |
302 | 299 | @mock.patch('pytest_reportportal.plugin.wait_launch', mock.Mock()) |
303 | | -def test_pytest_sessionstart_with_launch_id(mocked_session): |
304 | | - """Test session configuration if RP launch ID is set via command-line. |
| 300 | +def test_pytest_sessionstart_xdist(mocked_session): |
| 301 | + """Test session configuration if it's worker xdist node. |
305 | 302 |
|
306 | 303 | :param mocked_session: pytest fixture |
307 | 304 | """ |
308 | 305 | mocked_session.config.pluginmanager.hasplugin.return_value = True |
309 | | - mocked_session.config._reporter_config = mock.Mock( |
310 | | - spec=AgentConfig(mocked_session.config)) |
| 306 | + mocked_session.config._reporter_config = mock.Mock(spec=AgentConfig(mocked_session.config)) |
311 | 307 | mocked_session.config._reporter_config.rp_launch_attributes = [] |
312 | 308 | mocked_session.config._reporter_config.rp_launch_id = 1 |
| 309 | + mocked_session.config.workerinput = 1 |
313 | 310 | mocked_session.config.py_test_service = mock.Mock() |
314 | 311 | pytest_sessionstart(mocked_session) |
315 | | - expect(lambda: mocked_session.config.py_test_service.start_launch. |
316 | | - assert_not_called()) |
| 312 | + expect(lambda: mocked_session.config.py_test_service.start_launch.assert_not_called()) |
317 | 313 | assert_expectations() |
318 | 314 |
|
319 | 315 |
|
|
0 commit comments