diff --git a/pytest_deadfixtures.py b/pytest_deadfixtures.py index 7e323a6..f552693 100644 --- a/pytest_deadfixtures.py +++ b/pytest_deadfixtures.py @@ -12,7 +12,7 @@ DUPLICATE_FIXTURES_HEADLINE = "\n\nYou may have some duplicate fixtures:" UNUSED_FIXTURES_FOUND_HEADLINE = ( - "Hey there, I believe the following fixture(s) are not being used:" + "Hey there, I believe the following {count} fixture(s) are not being used:" ) UNUSED_FIXTURES_NOT_FOUND_HEADLINE = "Cool, every declared fixture is being used." @@ -209,7 +209,7 @@ def show_dead_fixtures(config, session): tw.line() if unused_fixtures: - tw.line(UNUSED_FIXTURES_FOUND_HEADLINE, red=True) + tw.line(UNUSED_FIXTURES_FOUND_HEADLINE.format(count=len(unused_fixtures)), red=True) write_fixtures(tw, unused_fixtures, show_fixture_doc) else: tw.line(UNUSED_FIXTURES_NOT_FOUND_HEADLINE, green=True) diff --git a/tests/test_deadfixtures.py b/tests/test_deadfixtures.py index 71f07d5..6955ec3 100644 --- a/tests/test_deadfixtures.py +++ b/tests/test_deadfixtures.py @@ -3,7 +3,7 @@ from pytest_deadfixtures import ( DUPLICATE_FIXTURES_HEADLINE, EXIT_CODE_ERROR, - EXIT_CODE_SUCCESS, + EXIT_CODE_SUCCESS, UNUSED_FIXTURES_FOUND_HEADLINE, ) @@ -111,8 +111,10 @@ def test_simple(): message = message_template.format( "same_file_fixture", "test_list_same_file_unused_fixture" ) + output = result.stdout.str() - assert message in result.stdout.str() + assert message in output + assert UNUSED_FIXTURES_FOUND_HEADLINE.format(count=1) in output def test_list_same_file_multiple_unused_fixture(pytester, message_template): @@ -147,6 +149,7 @@ def test_simple(): assert first in output assert second in output assert output.index(first) < output.index(second) + assert UNUSED_FIXTURES_FOUND_HEADLINE.format(count=2) in output def test_dont_list_conftest_fixture(pytester, message_template):