Skip to content

chores(src): nuke fixtures dir when html is disabled and no tests were filled #2014

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
25 changes: 22 additions & 3 deletions src/pytest_plugins/filler/filler.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import configparser
import datetime
import os
import shutil
import warnings
from enum import Enum
from pathlib import Path
Expand Down Expand Up @@ -1195,9 +1196,27 @@ def pytest_sessionfinish(session: pytest.Session, exitstatus: int):
if session.config.getoption("generate_index") and not session.config.getoption(
"generate_pre_alloc_groups"
):
generate_fixtures_index(
fixture_output.directory, quiet_mode=True, force_flag=False, disable_infer_format=False
)
# only create fixtures dir if at least one test was filled
amount_of_collected_tests = getattr(session, "testscollected", 0)
if amount_of_collected_tests > 0:
generate_fixtures_index(
fixture_output.directory,
quiet_mode=True,
force_flag=False,
disable_infer_format=False,
)
else:
# nuke the fixtures dir, but only if:
# * html output is disabled
# and
# * no tests were filled
html_output_is_enabled = getattr(session.config.option, "htmlpath", None)
if not html_output_is_enabled:
# determine chosen fixtures output folder
fixture_output_obj: FixtureOutput = FixtureOutput.from_config(session.config)
fixture_output_folder: Path = fixture_output_obj.output_path
# and delete it
shutil.rmtree(fixture_output_folder)

# Create tarball of the output directory if the output is a tarball.
fixture_output.create_tarball()
Loading