|
11 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | | - |
| 14 | +import sys |
15 | 15 | from collections import defaultdict |
16 | 16 | from unittest import mock |
17 | 17 |
|
18 | 18 | import pytest |
19 | 19 | from reportportal_client import set_current |
20 | 20 | from reportportal_client.steps import StepReporter |
21 | 21 |
|
| 22 | +from examples.fixtures.test_failure_fixture_teardown.conftest import ( |
| 23 | + LOG_MESSAGE_BEFORE_YIELD as LOG_MESSAGE_BEFORE_YIELD_TEST_FAILURE, |
| 24 | + LOG_MESSAGE_TEARDOWN as LOG_MESSAGE_TEARDOWN_TEST_FAILURE) |
| 25 | +from examples.fixtures.test_fixture_return_none.conftest import LOG_MESSAGE_SETUP as LOG_MESSAGE_BEFORE_RETURN_NONE |
22 | 26 | from examples.fixtures.test_fixture_setup.conftest import LOG_MESSAGE_SETUP as SINGLE_SETUP_MESSAGE |
23 | 27 | from examples.fixtures.test_fixture_setup_failure.conftest import LOG_MESSAGE_SETUP as LOG_MESSAGE_SETUP_FAILURE |
24 | 28 | from examples.fixtures.test_fixture_teardown.conftest import LOG_MESSAGE_BEFORE_YIELD, LOG_MESSAGE_TEARDOWN |
25 | 29 | from examples.fixtures.test_fixture_teardown_failure.conftest import ( |
26 | 30 | LOG_MESSAGE_BEFORE_YIELD as LOG_MESSAGE_BEFORE_YIELD_FAILURE, LOG_MESSAGE_TEARDOWN as LOG_MESSAGE_TEARDOWN_FAILURE) |
27 | 31 | from examples.fixtures.test_fixture_yield_none.conftest import LOG_MESSAGE_SETUP as LOG_MESSAGE_BEFORE_YIELD_NONE |
28 | | -from examples.fixtures.test_fixture_return_none.conftest import LOG_MESSAGE_SETUP as LOG_MESSAGE_BEFORE_RETURN_NONE |
29 | | -from examples.fixtures.test_failure_fixture_teardown.conftest import ( |
30 | | - LOG_MESSAGE_BEFORE_YIELD as LOG_MESSAGE_BEFORE_YIELD_TEST_FAILURE, |
31 | | - LOG_MESSAGE_TEARDOWN as LOG_MESSAGE_TEARDOWN_TEST_FAILURE) |
32 | 32 | from tests import REPORT_PORTAL_SERVICE |
33 | 33 | from tests.helpers import utils |
34 | 34 |
|
35 | | - |
36 | 35 | ITEM_ID_DICT = defaultdict(lambda: 0) |
37 | 36 | ITEM_ID_LIST = [] |
38 | 37 |
|
@@ -185,7 +184,10 @@ def test_fixture_setup_failure(mock_client_init): |
185 | 184 |
|
186 | 185 | start_count = mock_client.start_test_item.call_count |
187 | 186 | finish_count = mock_client.finish_test_item.call_count |
188 | | - assert start_count == finish_count == 2, 'Incorrect number of "start_test_item" or "finish_test_item" calls' |
| 187 | + if sys.version_info < (3, 8): |
| 188 | + assert start_count == finish_count == 3, 'Incorrect number of "start_test_item" or "finish_test_item" calls' |
| 189 | + else: |
| 190 | + assert start_count == finish_count == 2, 'Incorrect number of "start_test_item" or "finish_test_item" calls' |
189 | 191 |
|
190 | 192 | call_args = mock_client.start_test_item.call_args_list |
191 | 193 | setup_call_args = call_args[1][0] |
@@ -421,6 +423,7 @@ def test_failure_fixture_teardown(mock_client_init): |
421 | 423 | 'test_failure_fixture_teardown_1') |
422 | 424 |
|
423 | 425 |
|
| 426 | +@pytest.mark.skipif(sys.version_info < (3, 8), reason='Python 3.8+ required due to bugs in older versions') |
424 | 427 | @mock.patch(REPORT_PORTAL_SERVICE) |
425 | 428 | def test_session_fixture_setup(mock_client_init): |
426 | 429 | mock_client = mock_client_init.return_value |
@@ -450,6 +453,7 @@ def test_session_fixture_setup(mock_client_init): |
450 | 453 | assert not setup_call_kwargs['has_stats'] |
451 | 454 |
|
452 | 455 |
|
| 456 | +@pytest.mark.skipif(sys.version_info < (3, 8), reason='Python 3.8+ required due to bugs in older versions') |
453 | 457 | @mock.patch(REPORT_PORTAL_SERVICE) |
454 | 458 | def test_package_fixture_setup(mock_client_init): |
455 | 459 | mock_client = mock_client_init.return_value |
@@ -479,6 +483,7 @@ def test_package_fixture_setup(mock_client_init): |
479 | 483 | assert not setup_call_kwargs['has_stats'] |
480 | 484 |
|
481 | 485 |
|
| 486 | +@pytest.mark.skipif(sys.version_info < (3, 8), reason='Python 3.8+ required due to bugs in older versions') |
482 | 487 | @mock.patch(REPORT_PORTAL_SERVICE) |
483 | 488 | def test_module_fixture_setup(mock_client_init): |
484 | 489 | mock_client = mock_client_init.return_value |
@@ -508,6 +513,7 @@ def test_module_fixture_setup(mock_client_init): |
508 | 513 | assert not setup_call_kwargs['has_stats'] |
509 | 514 |
|
510 | 515 |
|
| 516 | +@pytest.mark.skipif(sys.version_info < (3, 8), reason='Python 3.8+ required due to bugs in older versions') |
511 | 517 | @mock.patch(REPORT_PORTAL_SERVICE) |
512 | 518 | def test_class_fixture_setup(mock_client_init): |
513 | 519 | mock_client = mock_client_init.return_value |
|
0 commit comments