Repository navigation
allure2 for pytest should using get_closest_marker to replace the get_marker #307
Copy link
Copy link
Closed
Description
I'm submitting a ...
- bug report
- feature request
- support request => Please do not submit support request here, see note at the top of this template.
What is the current behavior?
D:\workspace\mine\python\haf\testcases>python -m pytest two.py --alluredir=./
============================= test session starts =============================
platform win32 -- Python 3.6.6, pytest-3.10.1, py-1.5.4, pluggy-0.7.1
rootdir: D:\workspace\mine\python\haf, inifile:
plugins: metadata-1.7.0, html-1.19.0, allure-pytest-2.5.3
collected 1 item
two.py . [100%]
============================== warnings summary ===============================
testcases/two.py::Test_Allure::()::test_allure_pytest
C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\allure_pytest\utils.py:24: RemovedInPytest4Warning: MarkInfo objects are deprecated as they contain merged marks which are hard to deal with correctly.
Please use node.get_closest_marker(name) or node.iter_markers(name).
Docs: https://docs.pytest.org/en/latest/mark.html#updating-code
return marker.args[0] if marker and marker.args else None
C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\allure_pytest\utils.py:24: RemovedInPytest4Warning: MarkInfo objects are deprecated as they contain merged marks which are hard to deal with correctly.
Please use node.get_closest_marker(name) or node.iter_markers(name).
Docs: https://docs.pytest.org/en/latest/mark.html#updating-code
return marker.args[0] if marker and marker.args else None
C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\allure_pytest\utils.py:48: RemovedInPytest4Warning: MarkInfo objects are deprecated as they contain merged marks which are hard to deal with correctly.
Please use node.get_closest_marker(name) or node.iter_markers(name).
Docs: https://docs.pytest.org/en/latest/mark.html#updating-code
label_type = marker.kwargs['label_type']
C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\allure_pytest\utils.py:52: RemovedInPytest4Warning: MarkInfo objects are deprecated as they contain merged marks which are hard to deal with correctly.
Please use node.get_closest_marker(name) or node.iter_markers(name).
Docs: https://docs.pytest.org/en/latest/mark.html#updating-code
for value in marker.args:
-- Docs: https://docs.pytest.org/en/latest/warnings.html
==================== 1 passed, 4 warnings in 0.06 seconds =====================If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
1, using pytest 3.1.0 ==>
pip install pytest==3.1.0
2, using allure-pytest 2.5.3 ==>pip install allure-pytest==2.5.3
3, write an sample pytest case : using allure marker
import pytest, os, sys, allure
class Test_Allure:
@allure.description("test for allure")
@allure.story("test the allure in pytest case")
def test_allure_pytest(self):
print("test now")4,
python -m pytest two.py --alluredir=./
D:\workspace\mine\python\haf\testcases>python -m pytest two.py --alluredir=./
============================= test session starts =============================
platform win32 -- Python 3.6.6, pytest-3.10.1, py-1.5.4, pluggy-0.7.1
rootdir: D:\workspace\mine\python\haf, inifile:
plugins: metadata-1.7.0, html-1.19.0, allure-pytest-2.5.3
collected 1 item
two.py . [100%]
============================== warnings summary ===============================
testcases/two.py::Test_Allure::()::test_allure_pytest
C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\allure_pytest\utils.py:24: RemovedInPytest4Warning: MarkInfo objects are deprecated as they contain merged marks which are hard to deal with correctly.
Please use node.get_closest_marker(name) or node.iter_markers(name).
Docs: https://docs.pytest.org/en/latest/mark.html#updating-code
return marker.args[0] if marker and marker.args else None
C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\allure_pytest\utils.py:24: RemovedInPytest4Warning: MarkInfo objects are deprecated as they contain merged marks which are hard to deal with correctly.
Please use node.get_closest_marker(name) or node.iter_markers(name).
Docs: https://docs.pytest.org/en/latest/mark.html#updating-code
return marker.args[0] if marker and marker.args else None
C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\allure_pytest\utils.py:48: RemovedInPytest4Warning: MarkInfo objects are deprecated as they contain merged marks which are hard to deal with correctly.
Please use node.get_closest_marker(name) or node.iter_markers(name).
Docs: https://docs.pytest.org/en/latest/mark.html#updating-code
label_type = marker.kwargs['label_type']
C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\allure_pytest\utils.py:52: RemovedInPytest4Warning: MarkInfo objects are deprecated as they contain merged marks which are hard to deal with correctly.
Please use node.get_closest_marker(name) or node.iter_markers(name).
Docs: https://docs.pytest.org/en/latest/mark.html#updating-code
for value in marker.args:
-- Docs: https://docs.pytest.org/en/latest/warnings.html
==================== 1 passed, 4 warnings in 0.06 seconds =====================What is the expected behavior?
No warnings in the pytest when using the allure markers
What is the motivation / use case for changing the behavior?
https://docs.pytest.org/en/latest/mark.html#updating-code
using function of pytest
get_closet_marker' to replace theget_marker'
in utils.py,
in function
allure_labelsandallure_links, usingget_closet_marker' to replace theget_marker'
in functionget_marker_value, usingget_closest_markerto replacekeywords.get
# in utils.py
def get_marker_value(item, keyword):
#marker = item.keywords.get(keyword)
marker = item.get_closest_marker(keyword)
return marker.args[0] if marker and marker.args else None
def allure_labels(item):
for keyword in item.keywords.keys():
if keyword.startswith(ALLURE_LABEL_PREFIX):
#marker = item.get_marker(keyword)
marker = item.get_closest_marker(keyword)
label_type = marker.kwargs['label_type']
if label_type in ALLURE_UNIQUE_LABELS:
yield (label_type, marker.args[0])
else:
for value in marker.args:
yield (label_type, value)
def allure_links(item):
for keyword in item.keywords.keys():
if keyword.startswith(ALLURE_LINK_PREFIX):
#marker = item.get_marker(keyword)
marker = item.get_closest_marker(keyword)
link_type = marker.kwargs['link_type']
url = marker.args[0]
name = marker.kwargs['name']
yield (link_type, url, name)Please tell us about your environment:
| Allure version | 2.5.3 |
|---|---|
| Test framework | pytest@3.10.1 |
| Allure adaptor | allure-pytest@2.5.3 |
| Generate report using | allure-pytest@2.5.3 |
Other information
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels


Activity
sseliverstov commentedon Nov 19, 2018
fixed in #306