Skip to content

Commit

Permalink
fixed bug when test is not inside any package (via allure-framework#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sup3rGeo authored and skhomuti committed Nov 18, 2020
1 parent 755d2d4 commit 67c5916
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion allure-pytest/src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def allure_suite_labels(item):
clazz = possibly_clazz if tail else None
file_name, path = islice(chain(reversed(head.rsplit('/', 1)), [None]), 2)
module = file_name.split('.')[0]
package = path.replace('/', '.')
package = path.replace('/', '.') if path else None
pairs = zip([LabelType.PARENT_SUITE, LabelType.SUITE, LabelType.SUB_SUITE], [package, module, clazz])
return [(name, value) for name, value in pairs if value is not None]

Expand Down
17 changes: 17 additions & 0 deletions allure-pytest/test/labels/package/package_less_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
def test_with_no_package(testdir, request):
"""
Test where parent package is None
>>> allure_report = getfixture('allure_report_with_params')('-p pytester')
>>> assert_that(allure_report,
... has_test_case('test_with_no_package',
... with_status('passed')
... )
... )
"""
testdir.makepyfile('''
def test_simple(request):
pass
''')
result = testdir.runpytest_subprocess('--alluredir=allure')
assert result.ret == 0

0 comments on commit 67c5916

Please sign in to comment.