Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add unused fixtures count #36

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pytest_deadfixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."

Expand Down Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions tests/test_deadfixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pytest_deadfixtures import (
DUPLICATE_FIXTURES_HEADLINE,
EXIT_CODE_ERROR,
EXIT_CODE_SUCCESS,
EXIT_CODE_SUCCESS, UNUSED_FIXTURES_FOUND_HEADLINE,
)


Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down