allure-python icon indicating copy to clipboard operation
allure-python copied to clipboard

Pytest 4.5.0 now displays warning for non declared markers (Eventually errors)

Open symonk opened this issue 7 years ago • 13 comments

When using allure, we are now seeing the following outputs with pytest 4.5.0 (These warnings are eventually going to become errors in pytest 4.6.0 (or some time similar)

some (but not all examples are):

PytestUnknownMarkWarning,_pytest/mark/structures.py:324: PytestUnknownMarkWarning: Unknown pytest.mark.allure_label.epic - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/latest/mark.html PytestUnknownMarkWarning,

pytest.mark.allure_label.feature - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/latest/mark.html PytestUnknownMarkWarning,

pytest.mark.allure_label.story - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/latest/mark.htmlPytestUnknownMarkWarning,

#5023: New flag --strict-markers that triggers an error when unknown markers (e.g. those not registered using the markers option in the configuration file) are used in the test suite.

The existing --strict option has the same behavior currently, but can be augmented in the future for additional checks.

https://docs.pytest.org/en/latest/changelog.html

symonk avatar May 28 '19 07:05 symonk

This is a big problem for allure, especially in future because of:

packages/_pytest/mark/structures.py:324: PytestUnknownMarkWarning: Unknown pytest.mark.allure_link.issue:PE-28550 - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/latest/mark.html PytestUnknownMarkWarning,

These markers are dynamic

@sseliverstov thoughts?

symonk avatar May 28 '19 08:05 symonk

From Py.Test docs: Registered marks appear in pytest’s help text and do not emit warnings (see the next section). It is recommended that third-party plugins always register their markers. Registering custom markers.

For demo purposes, I loaded up https://github.com/ehborisov/allure2-pytest-demo and ran with pytest 4.5.0. I was able to get around a bunch for now, using the pytest.ini file like so:

addopts = --strict-markers
markers =
    allure_description: Allure Marker
    allure_description_html: Allure Marker
    allure_link: Allure Marker
    allure_link.link: Allure Marker
    allure_link.issue: Allure Marker
    allure_label.feature: Allure Marker
    allure_title: Allure Marker

I noticed was everything in this test file was broken, and unable to be added to the pytest.ini file. . For some reason, the marker was including the actual link if you look at the '. This was for all the tests in the above linked file (allure pytest demo)

allure.link marking #1

@allure.feature('Links')
@allure.link('https://www.youtube.com/watch?v=4YYzUTYZRMU')

Error for #1

'allure_link.link:https://www.youtube.com/watch?v=4YYzUTYZRMU' not found in `markers` configuration option

allure.link marking #2

@allure.feature('Links')
@allure.link('https://www.youtube.com/watch?v=Su5p2TqZxKU', name='Click me')

Error:

'allure_link.link: https://www.youtube.com/watch?v=Su5p2TqZxKU' not found in `markers` configuration option

allure.link.issue marking:

@allure.feature('Links')
@allure.issue('140', 'Pytest-flaky test retries shows like test steps')

Error:

'allure_link.issue:140' not found in `markers` configuration option

Allure testcase marking:

TEST_CASE_LINK = 'https://github.com/qameta/allure-integrations/issues/8#issuecomment-268313637'

@allure.feature('Links')
@allure.testcase(TEST_CASE_LINK, 'Test case title')

Error:

'allure_link.test_case:https://github.com/qameta/allure-integrations/issues/8#issuecomment-268313637' not found in `markers` configuration option

Even when adding the whole of what is in single quotes as a mark. (most likely from the parsing of the file having multiple :

Hope this helps those with warning, and those awesome amazing folks maintaining Allure!

mlewandowskipear avatar May 28 '19 19:05 mlewandowskipear

Hi, i had the same problem. Are there any updates ?

AnastasiiaLatysh avatar Jun 11 '19 08:06 AnastasiiaLatysh

The current pytest plan is to just do bugfixes until the py2 depreciation. https://docs.pytest.org/en/latest/py27-py34-deprecation.html Likely, this will mean we can live in the warning state for a while, and the 'eventually errors' is quite a while away.

mlewandowskipear avatar Jun 11 '19 19:06 mlewandowskipear

This is very annoying.

ghost avatar Jun 25 '19 15:06 ghost

will be fixed on next release

sseliverstov avatar Jun 26 '19 16:06 sseliverstov

Still have this issue in pytest 5.0.1 Fixed by adding filter into pytest.ini

[pytest]
filterwarnings = ignore:.*PytestUnknownMarkWarning*

ghost avatar Jul 26 '19 08:07 ghost

@akropyva-apixio may i know the file location of pytest.ini, and can you please elaborate what changes you did to make it run.

Thanks in Advance, Dilip

dilipvaze avatar Aug 07 '19 09:08 dilipvaze

@dilipvaze purest.ini is located into root directory. pytest -m active_time_hcc -v -s -n 3 --reportportal --rp-launch="Active Time HCC Identifier" [pytest] filterwarnings = ignore:.PytestUnknownMarkWarning log_level=INFO log_format = %(asctime)s %(levelname)s %(message)s log_date_format = %Y-%m-%d %H:%M:%S rp_uuid = 1111 rp_endpoint = 1111 rp_project = 1111 rp_verify_ssl = False markers = integration_hcc api_hcc api_quality_id ui_quality_id ui_sanity_hcc ui_flows_hcc v22 v23 react_product angular_product reject_structure skp_functionality accept_functionality reject_functionality accept_structure team_page project_settings_page project_history proj_history_search project_history_permission productivity_coders demo doc_gap docgap test_dashboard_pages icd_filter project_history_new dashboard qa_routing rebundle state_machine manual_coding active_time_hcc_full v23optum large_v22_history v23combined active_time_hcc active_time_hcc_phases active_opps_per_hour ui_flows

ghost avatar Aug 07 '19 11:08 ghost

@akropyva-apixio @dilipvaze Can you show full text of warnings? If it allure markers I will fix it

sseliverstov avatar Aug 07 '19 11:08 sseliverstov

@sseliverstov This is the full text of the warning:

foo-ve/lib/python3.6/site-packages/_pytest/mark/structures.py:327

    /builds/Carrene/owl/owl-ve/lib/python3.6/site-packages/_pytest/mark/structures.py:327: PytestUnknownMarkWarning: Unknown pytest.mark.asyncio - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/latest/mark.html

    PytestUnknownMarkWarning,
-- Docs: https://docs.pytest.org/en/latest/warnings.html```

`pytest==5.3.1`

masoodkazemi94 avatar Jan 04 '20 17:01 masoodkazemi94

This is not Robot framework related, you have a pytest marker asyncio that needs to be added to your pytest.ini file, under markers.

[pytest]
markers =
   asyncio

mlewandowskipear avatar Jan 06 '20 21:01 mlewandowskipear

I see this issue with 2.222.1 also.

My pytest.ini contains:

[pytest]
markers =
    smoke: mark test as smoke test

Warning Unknown pytest.mark.smoke - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/latest/mark.html

Vikash082 avatar Apr 15 '20 13:04 Vikash082