Skip to content

Commit

Permalink
Merge pull request Teemu#154 from albertodonato/fix-double-colon-in-f…
Browse files Browse the repository at this point in the history
…ilename

don't substitute dots with double colons in filename (fixes Teemu#153)
  • Loading branch information
Teemu authored Oct 24, 2018
2 parents fe1e991 + 56c085d commit e8cb804
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
5 changes: 4 additions & 1 deletion pytest_sugar.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,10 @@ def begin_new_line(self, report, print_filename):
else:
test_location = fspath[0:-len(basename)]
test_name = fspath[-len(basename):]
test_name = test_name.replace('.', '::')
if test_location:
# only replace if test_location is not empty, if it is,
# test_name contains the filename
test_name = test_name.replace('.', '::')
self.current_lines[path] = (
" " +
colored(test_location, THEME['path']) +
Expand Down
22 changes: 17 additions & 5 deletions test_sugar.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,6 @@ def test_xfail():
def test_verbose_has_double_colon(self, testdir):
testdir.makepyfile(
"""
import pytest
def test_true():
assert True
"""
Expand All @@ -478,11 +476,9 @@ def test_true():
def test_verbose_has_double_colon_with_class(self, testdir):
testdir.makepyfile(
"""
import pytest
class TestTrue:
def test_true():
def test_true(self):
assert True
"""
)
Expand All @@ -494,6 +490,22 @@ def test_true():
'test_verbose_has_double_colon_with_class.py::TestTrue::test_true')
assert test_name in strip_colors(output)

def test_not_verbose_no_double_colon_filename(self, testdir):
testdir.makepyfile(
"""
class TestTrue:
def test_true(self):
assert True
"""
)
output = testdir.runpytest(
'--force-sugar'
).stdout.str()

test_name = 'test_not_verbose_no_double_colon_filename.py'
assert test_name in strip_colors(output)

def test_xdist(self, testdir):
pytest.importorskip("xdist")
testdir.makepyfile(
Expand Down

0 comments on commit e8cb804

Please sign in to comment.