Skip to content

Commit 0e341a5

Browse files
Sup3rGeosseliverstov
authored andcommitted
fixed bug when test is not inside any package (via #287)
1 parent c37b8b0 commit 0e341a5

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

allure-pytest/src/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def allure_suite_labels(item):
106106
clazz = possibly_clazz if tail else None
107107
file_name, path = islice(chain(reversed(head.rsplit('/', 1)), [None]), 2)
108108
module = file_name.split('.')[0]
109-
package = path.replace('/', '.')
109+
package = path.replace('/', '.') if path else None
110110
pairs = zip([LabelType.PARENT_SUITE, LabelType.SUITE, LabelType.SUB_SUITE], [package, module, clazz])
111111
return [(name, value) for name, value in pairs if value is not None]
112112

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
def test_with_no_package(testdir, request):
2+
"""
3+
Test where parent package is None
4+
>>> allure_report = getfixture('allure_report_with_params')('-p pytester')
5+
>>> assert_that(allure_report,
6+
... has_test_case('test_with_no_package',
7+
... with_status('passed')
8+
... )
9+
... )
10+
"""
11+
testdir.makepyfile('''
12+
def test_simple(request):
13+
pass
14+
''')
15+
result = testdir.runpytest_subprocess('--alluredir=allure')
16+
assert result.ret == 0
17+

0 commit comments

Comments
 (0)