From 095db2a140d48df4fa7bc35d4a343dbe20fd492f Mon Sep 17 00:00:00 2001 From: Stas Seliverstov Date: Mon, 19 Nov 2018 17:24:18 +0300 Subject: [PATCH] remove deprecated pytest namespace --- allure-pytest/src/plugin.py | 4 ---- .../attachments/attachments_fixtures_test.py | 4 ++-- .../test/attachments/attachments_test.py | 14 ++++++------ .../test/filtering/severity_label_test.py | 12 +++++----- .../labels/severity/class_severity_test.py | 8 +++---- .../labels/severity/function_severity_test.py | 4 ++-- .../labels/severity/module_severity_test.py | 8 +++---- .../test/links/function_links_test.py | 22 +++++++++---------- .../test/links/links_pattern_test.py | 4 ++-- .../test/status/base_step_status_test.py | 7 +++--- .../test/status/skip_step_status_test.py | 3 ++- .../test/status/xfail_step_status_test.py | 3 ++- allure-pytest/test/steps/nested_steps_test.py | 4 ++-- 13 files changed, 48 insertions(+), 49 deletions(-) diff --git a/allure-pytest/src/plugin.py b/allure-pytest/src/plugin.py index 30558045..b0e1577a 100644 --- a/allure-pytest/src/plugin.py +++ b/allure-pytest/src/plugin.py @@ -132,7 +132,3 @@ def pytest_collection_modifyitems(items, config): config.option.allure_severities) items[:] = filter(lambda item: arg_labels & set(allure_labels(item)) if arg_labels else True, items) - - -def pytest_namespace(): - return {"allure": allure} diff --git a/allure-pytest/test/attachments/attachments_fixtures_test.py b/allure-pytest/test/attachments/attachments_fixtures_test.py index 8b86c60c..7acc7227 100644 --- a/allure-pytest/test/attachments/attachments_fixtures_test.py +++ b/allure-pytest/test/attachments/attachments_fixtures_test.py @@ -6,7 +6,7 @@ @pytest.fixture def attach_file_in_function_scope_fixture(svg_file): - allure.attach.file(svg_file, attachment_type=pytest.allure.attachment_type.SVG) + allure.attach.file(svg_file, attachment_type=allure.attachment_type.SVG) def test_attach_file_in_function_scope_fixture(attach_file_in_function_scope_fixture): @@ -44,7 +44,7 @@ def test_attach_file_in_reused_function_scope_fixture(attach_file_in_function_sc @pytest.fixture def attach_file_in_function_scope_finalizer(svg_file, request): def finalizer_function_scope_fixture(): - allure.attach.file(svg_file, attachment_type=pytest.allure.attachment_type.SVG) + allure.attach.file(svg_file, attachment_type=allure.attachment_type.SVG) request.addfinalizer(finalizer_function_scope_fixture) diff --git a/allure-pytest/test/attachments/attachments_test.py b/allure-pytest/test/attachments/attachments_test.py index ecd07bf4..ecff8d6c 100644 --- a/allure-pytest/test/attachments/attachments_test.py +++ b/allure-pytest/test/attachments/attachments_test.py @@ -34,7 +34,7 @@ def test_attach_file_from_test_with_name_and_type(xml_file): ... has_attachment(attach_type='application/xml', name='my name') ... )) """ - allure.attach.file(xml_file, name='my name', attachment_type=pytest.allure.attachment_type.XML) + allure.attach.file(xml_file, name='my name', attachment_type=allure.attachment_type.XML) def test_attach_data_from_test_with_name_and_type(xml_body): @@ -45,7 +45,7 @@ def test_attach_data_from_test_with_name_and_type(xml_body): ... has_attachment(attach_type='application/xml', name='my name') ... )) """ - allure.attach(xml_body, name='my name', attachment_type=pytest.allure.attachment_type.XML) + allure.attach(xml_body, name='my name', attachment_type=allure.attachment_type.XML) def test_attach_file_from_test_with_user_type(xml_file): @@ -71,7 +71,7 @@ def test_attach_data_from_test_with_user_type(xml_body): def attach_svg_file(svg_file): - allure.attach.file(svg_file, attachment_type=pytest.allure.attachment_type.SVG) + allure.attach.file(svg_file, attachment_type=allure.attachment_type.SVG) def test_attach_file_from_function(svg_file): @@ -96,7 +96,7 @@ def test_many_attaches(svg_file, xml_body): ... )) """ attach_svg_file(svg_file) - allure.attach(xml_body, attachment_type=pytest.allure.attachment_type.XML) + allure.attach(xml_body, attachment_type=allure.attachment_type.XML) def test_attach_from_step(svg_file, xml_body): @@ -115,6 +115,6 @@ def test_attach_from_step(svg_file, xml_body): ... ) """ with allure.step('Step with attachment'): - allure.attach.file(svg_file, attachment_type=pytest.allure.attachment_type.SVG) - with pytest.allure.step('Nested step with attachment'): - allure.attach(xml_body, attachment_type=pytest.allure.attachment_type.XML) + allure.attach.file(svg_file, attachment_type=allure.attachment_type.SVG) + with allure.step('Nested step with attachment'): + allure.attach(xml_body, attachment_type=allure.attachment_type.XML) diff --git a/allure-pytest/test/filtering/severity_label_test.py b/allure-pytest/test/filtering/severity_label_test.py index 9c7bdd2b..38dc4b25 100644 --- a/allure-pytest/test/filtering/severity_label_test.py +++ b/allure-pytest/test/filtering/severity_label_test.py @@ -7,10 +7,10 @@ ... )) # doctest: +SKIP """ -import pytest +import allure -@pytest.allure.severity(pytest.allure.severity_level.TRIVIAL) +@allure.severity(allure.severity_level.TRIVIAL) def test_function_with_trivial_severity(): """ >>> allure_report = getfixture('allure_report_with_params')('--allure-severities=trivial') @@ -25,7 +25,7 @@ def test_function_with_trivial_severity(): class TestClass(object): - @pytest.allure.severity(pytest.allure.severity_level.TRIVIAL) + @allure.severity(allure.severity_level.TRIVIAL) def test_method_with_trivial_severity(self): """ >>> allure_report = getfixture('allure_report_with_params')('--allure-severities=trivial') @@ -37,7 +37,7 @@ def test_method_with_trivial_severity(self): """ pass - @pytest.allure.severity(pytest.allure.severity_level.NORMAL) + @allure.severity(allure.severity_level.NORMAL) def test_method_with_normal_severity(self): """ >>> from hamcrest import not_ @@ -49,7 +49,7 @@ def test_method_with_normal_severity(self): pass -@pytest.allure.severity(pytest.allure.severity_level.TRIVIAL) +@allure.severity(allure.severity_level.TRIVIAL) class TestClassAgain(object): def test_method_with_whole_class_trivial_severity(self): @@ -63,7 +63,7 @@ def test_method_with_whole_class_trivial_severity(self): """ pass - @pytest.allure.severity(pytest.allure.severity_level.NORMAL) + @allure.severity(allure.severity_level.NORMAL) def test_method_with_overridden_class_severity(self): """ >>> from hamcrest import not_ diff --git a/allure-pytest/test/labels/severity/class_severity_test.py b/allure-pytest/test/labels/severity/class_severity_test.py index 5d35c054..87396834 100644 --- a/allure-pytest/test/labels/severity/class_severity_test.py +++ b/allure-pytest/test/labels/severity/class_severity_test.py @@ -9,10 +9,10 @@ """ -import pytest +import allure -@pytest.allure.severity(pytest.allure.severity_level.TRIVIAL) +@allure.severity(allure.severity_level.TRIVIAL) class TestDecoratedClass(object): def test_not_decorated_method(self): @@ -26,7 +26,7 @@ def test_not_decorated_method(self): """ pass - @pytest.allure.severity(pytest.allure.severity_level.MINOR) + @allure.severity(allure.severity_level.MINOR) def test_decorated_method(self): """ >>> allure_report = getfixture('allure_report') @@ -54,7 +54,7 @@ def test_not_decorated_method(self): """ pass - @pytest.allure.severity(pytest.allure.severity_level.CRITICAL) + @allure.severity(allure.severity_level.CRITICAL) def test_decorated_method(self): """ >>> allure_report = getfixture('allure_report') diff --git a/allure-pytest/test/labels/severity/function_severity_test.py b/allure-pytest/test/labels/severity/function_severity_test.py index e3efb640..eb9b1d75 100644 --- a/allure-pytest/test/labels/severity/function_severity_test.py +++ b/allure-pytest/test/labels/severity/function_severity_test.py @@ -1,7 +1,7 @@ -import pytest +import allure -@pytest.allure.severity(pytest.allure.severity_level.MINOR) +@allure.severity(allure.severity_level.MINOR) def test_decorated_function(): """ >>> allure_report = getfixture('allure_report') diff --git a/allure-pytest/test/labels/severity/module_severity_test.py b/allure-pytest/test/labels/severity/module_severity_test.py index a0cce2a9..883ba252 100644 --- a/allure-pytest/test/labels/severity/module_severity_test.py +++ b/allure-pytest/test/labels/severity/module_severity_test.py @@ -7,9 +7,9 @@ ... )) # doctest: +SKIP """ -import pytest +import allure -pytestmark = pytest.allure.severity(pytest.allure.severity_level.TRIVIAL) +pytestmark = allure.severity(allure.severity_level.TRIVIAL) def test_not_decorated_function(): @@ -24,7 +24,7 @@ def test_not_decorated_function(): pass -@pytest.allure.severity(pytest.allure.severity_level.MINOR) +@allure.severity(allure.severity_level.MINOR) def test_decorated_function(): """ >>> allure_report = getfixture('allure_report') @@ -51,7 +51,7 @@ def test_method_of_not_decorated_class(self): pass -@pytest.allure.severity(pytest.allure.severity_level.NORMAL) +@allure.severity(allure.severity_level.NORMAL) class TestDecorated(object): def test_method_of_decorated_class(self): diff --git a/allure-pytest/test/links/function_links_test.py b/allure-pytest/test/links/function_links_test.py index 8c21faf9..40d54fb9 100644 --- a/allure-pytest/test/links/function_links_test.py +++ b/allure-pytest/test/links/function_links_test.py @@ -8,7 +8,7 @@ ... )) # doctest: +SKIP """ -import pytest +import allure LINK = 'http://qameta.io' LINK_NAME = 'QAMETA' @@ -20,7 +20,7 @@ TEST_CASE_NAME = 'Comment with spec' -@pytest.allure.link(LINK) +@allure.link(LINK) def test_single_link(): """ >>> allure_report = getfixture('allure_report') @@ -33,7 +33,7 @@ def test_single_link(): pass -@pytest.allure.link(LINK, name=LINK_NAME) +@allure.link(LINK, name=LINK_NAME) def test_single_named_link(): """ >>> allure_report = getfixture('allure_report') @@ -46,7 +46,7 @@ def test_single_named_link(): pass -@pytest.allure.link(LINK, name=LINK_NAME, link_type=LINK_TYPE) +@allure.link(LINK, name=LINK_NAME, link_type=LINK_TYPE) def test_single_named_link_with_custom_type(): """ >>> allure_report = getfixture('allure_report') @@ -58,7 +58,7 @@ def test_single_named_link_with_custom_type(): pass -@pytest.allure.issue(ISSUE) +@allure.issue(ISSUE) def test_single_issue(): """ >>> allure_report = getfixture('allure_report') @@ -70,7 +70,7 @@ def test_single_issue(): pass -@pytest.allure.testcase(TEST_CASE) +@allure.testcase(TEST_CASE) def test_single_test_case(): """ >>> allure_report = getfixture('allure_report') @@ -82,9 +82,9 @@ def test_single_test_case(): pass -@pytest.allure.link(LINK, name=LINK_NAME, link_type=LINK_TYPE) -@pytest.allure.testcase(TEST_CASE, name=TEST_CASE_NAME) -@pytest.allure.issue(ISSUE, name=ISSUE_NAME) +@allure.link(LINK, name=LINK_NAME, link_type=LINK_TYPE) +@allure.testcase(TEST_CASE, name=TEST_CASE_NAME) +@allure.issue(ISSUE, name=ISSUE_NAME) def test_with_links_cases_and_issues(): """ >>> allure_report = getfixture('allure_report') @@ -98,8 +98,8 @@ def test_with_links_cases_and_issues(): pass -@pytest.allure.testcase(TEST_CASE, name="First") -@pytest.allure.testcase(ANOTHER_TEST_CASE, name="Second") +@allure.testcase(TEST_CASE, name="First") +@allure.testcase(ANOTHER_TEST_CASE, name="Second") def test_multiply_some_type_links(): """ >>> allure_report = getfixture('allure_report') diff --git a/allure-pytest/test/links/links_pattern_test.py b/allure-pytest/test/links/links_pattern_test.py index f2785d6d..25ec0f28 100644 --- a/allure-pytest/test/links/links_pattern_test.py +++ b/allure-pytest/test/links/links_pattern_test.py @@ -9,8 +9,8 @@ CUSTOM_LINK = 'pytest' -@pytest.allure.issue(ISSUE) -@pytest.allure.link(CUSTOM_LINK, link_type=CUSTOM_LINK_TYPE) +@allure.issue(ISSUE) +@allure.link(CUSTOM_LINK, link_type=CUSTOM_LINK_TYPE) def test_link_pattern(): """ >>> allure_report = getfixture('allure_report_with_params')('--allure-link-pattern=issue:{pattern}'.format( diff --git a/allure-pytest/test/status/base_step_status_test.py b/allure-pytest/test/status/base_step_status_test.py index 4b91a0f4..0530a854 100644 --- a/allure-pytest/test/status/base_step_status_test.py +++ b/allure-pytest/test/status/base_step_status_test.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import pytest +import allure def test_broken_step(): @@ -20,7 +21,7 @@ def test_broken_step(): ... ) ... ) """ - with pytest.allure.step('Step'): + with allure.step('Step'): raise ZeroDivisionError @@ -42,7 +43,7 @@ def test_pytest_fail_in_step(): ... ) ... ) """ - with pytest.allure.step('Step'): + with allure.step('Step'): pytest.fail() @@ -64,5 +65,5 @@ def test_pytest_bytes_data_in_assert(): ... ) ... ) """ - with pytest.allure.step('Step'): + with allure.step('Step'): assert '0\x82' == 1 diff --git a/allure-pytest/test/status/skip_step_status_test.py b/allure-pytest/test/status/skip_step_status_test.py index d383e91d..a72e7504 100644 --- a/allure-pytest/test/status/skip_step_status_test.py +++ b/allure-pytest/test/status/skip_step_status_test.py @@ -1,4 +1,5 @@ import pytest +import allure def test_skip_in_step(): @@ -17,5 +18,5 @@ def test_skip_in_step(): ... ) ... ) """ - with pytest.allure.step('Step'): + with allure.step('Step'): pytest.skip() diff --git a/allure-pytest/test/status/xfail_step_status_test.py b/allure-pytest/test/status/xfail_step_status_test.py index ebdbdcbf..280807bb 100644 --- a/allure-pytest/test/status/xfail_step_status_test.py +++ b/allure-pytest/test/status/xfail_step_status_test.py @@ -1,4 +1,5 @@ import pytest +import allure @pytest.mark.xfail() @@ -20,5 +21,5 @@ def test_xfail_step_failure(): ... ) ... ) """ - with pytest.allure.step('Step'): + with allure.step('Step'): assert False diff --git a/allure-pytest/test/steps/nested_steps_test.py b/allure-pytest/test/steps/nested_steps_test.py index 89aa1e10..21018eb4 100644 --- a/allure-pytest/test/steps/nested_steps_test.py +++ b/allure-pytest/test/steps/nested_steps_test.py @@ -52,7 +52,7 @@ @pytest.mark.parametrize("first_fail_before_second, first_fail_after_second, second_fail", fruit_machine) def test_nested_steps_inside_test(first_fail_before_second, first_fail_after_second, second_fail): - with pytest.allure.step('First step'): + with allure.step('First step'): assert not first_fail_before_second with allure.step('Second step'): assert not second_fail @@ -91,7 +91,7 @@ def test_mixed_nested_steps(first_fail_before_second, first_fail_after_second, s @pytest.mark.parametrize("first_fail_before_second, first_fail_after_second, second_fail", fruit_machine) def test_again_mixed_nested_steps(first_fail_before_second, first_fail_after_second, second_fail): - with pytest.allure.step('First step'): + with allure.step('First step'): assert not first_fail_before_second second_step(second_fail) assert not first_fail_after_second