Skip to content

Commit e6dbe8e

Browse files
Ivan-Feofanovjairhenrique
authored andcommitted
add unused fixtures count
1 parent 28605dc commit e6dbe8e

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

pytest_deadfixtures.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
DUPLICATE_FIXTURES_HEADLINE = "\n\nYou may have some duplicate fixtures:"
1515
UNUSED_FIXTURES_FOUND_HEADLINE = (
16-
"Hey there, I believe the following fixture(s) are not being used:"
16+
"Hey there, I believe the following {count} fixture(s) are not being used:"
1717
)
1818
UNUSED_FIXTURES_NOT_FOUND_HEADLINE = "Cool, every declared fixture is being used."
1919

@@ -228,7 +228,7 @@ def show_dead_fixtures(config, session):
228228

229229
tw.line()
230230
if unused_fixtures:
231-
tw.line(UNUSED_FIXTURES_FOUND_HEADLINE, red=True)
231+
tw.line(UNUSED_FIXTURES_FOUND_HEADLINE.format(count=len(unused_fixtures)), red=True)
232232
write_fixtures(tw, unused_fixtures, show_fixture_doc)
233233
else:
234234
tw.line(UNUSED_FIXTURES_NOT_FOUND_HEADLINE, green=True)

tests/test_deadfixtures.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from pytest_deadfixtures import (
44
DUPLICATE_FIXTURES_HEADLINE,
55
EXIT_CODE_ERROR,
6-
EXIT_CODE_SUCCESS,
6+
EXIT_CODE_SUCCESS, UNUSED_FIXTURES_FOUND_HEADLINE,
77
)
88

99

@@ -141,8 +141,10 @@ def test_simple():
141141
message = message_template.format(
142142
"same_file_fixture", "test_list_same_file_unused_fixture"
143143
)
144+
output = result.stdout.str()
144145

145-
assert message in result.stdout.str()
146+
assert message in output
147+
assert UNUSED_FIXTURES_FOUND_HEADLINE.format(count=1) in output
146148

147149

148150
def test_list_same_file_multiple_unused_fixture(pytester, message_template):
@@ -177,6 +179,7 @@ def test_simple():
177179
assert first in output
178180
assert second in output
179181
assert output.index(first) < output.index(second)
182+
assert UNUSED_FIXTURES_FOUND_HEADLINE.format(count=2) in output
180183

181184

182185
def test_dont_list_conftest_fixture(pytester, message_template):

0 commit comments

Comments
 (0)