File tree Expand file tree Collapse file tree 3 files changed +25
-9
lines changed
acceptance/parametrization
integration/pytest_doctest Expand file tree Collapse file tree 3 files changed +25
-9
lines changed Original file line number Diff line number Diff line change @@ -114,13 +114,11 @@ def allure_name(item, parameters):
114114 return SafeFormatter ().format (title , ** {** parameters , ** item .funcargs }) if title else name
115115
116116
117- def allure_full_name (item ):
118- parts = item .nodeid .split ('::' )
117+ def allure_full_name (item : pytest .Item ):
119118 package = allure_package (item )
120- clazz = '.{clazz}' .format (clazz = parts [1 ]) if len (parts ) > 2 else ''
121- test_with_params = parts [- 1 ]
122- test = test_with_params .rsplit ("[" , 1 )[0 ]
123- full_name = '{package}{clazz}#{test}' .format (package = package , clazz = clazz , test = test )
119+ class_name = f".{ item .parent .name } " if isinstance (item .parent , pytest .Class ) else ''
120+ test = item .originalname if isinstance (item , pytest .Function ) else item .name .split ("[" )[0 ]
121+ full_name = f'{ package } { class_name } #{ test } '
124122 return escape_name (full_name )
125123
126124
Original file line number Diff line number Diff line change 11import pytest
2- from hamcrest import assert_that
2+ from hamcrest import assert_that , has_entry , ends_with
33from allure_commons_test .report import has_test_case
44from allure_commons_test .result import has_parameter , with_excluded , with_mode
55
@@ -173,3 +173,21 @@ def test_dynamic_parameter_override_from_fixture(executed_docstring_source):
173173 has_parameter ("param1" , "'readable-value'" )
174174 )
175175 )
176+
177+
178+ def test_fullname_with_braces (executed_docstring_source ):
179+ """
180+ >>> import pytest
181+ ... import allure
182+
183+ >>> class TestClass:
184+ ... @pytest.mark.parametrize("param1", ["qwe]["])
185+ ... def test_with_braces(self, param1):
186+ ... pass
187+ """
188+ assert_that (executed_docstring_source .allure_report ,
189+ has_test_case ("test_with_braces[qwe][]" ,
190+ has_entry ('fullName' , ends_with (".TestClass#test_with_braces" )),
191+ has_parameter ("param1" , "'qwe]['" )
192+ )
193+ )
Original file line number Diff line number Diff line change 55
66
77@allure .feature ("Integration" )
8- def test_pytest_docktest (allured_testdir ):
8+ def test_pytest_doctest (allured_testdir ):
99 allured_testdir .testdir .makepyfile ('''
1010 def some_func():
1111 """
@@ -19,6 +19,6 @@ def some_func():
1919 allured_testdir .run_with_allure ("--doctest-modules" )
2020
2121 assert_that (allured_testdir .allure_report ,
22- has_test_case ("test_pytest_docktest .some_func" ,
22+ has_test_case ("test_pytest_doctest .some_func" ,
2323 with_status ("passed" ))
2424 )
You can’t perform that action at this time.
0 commit comments