File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed
src/pytest_plugins/filler Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change 9
9
import configparser
10
10
import datetime
11
11
import os
12
+ import shutil
12
13
import warnings
13
14
from enum import Enum
14
15
from pathlib import Path
@@ -1195,9 +1196,23 @@ def pytest_sessionfinish(session: pytest.Session, exitstatus: int):
1195
1196
if session .config .getoption ("generate_index" ) and not session .config .getoption (
1196
1197
"generate_pre_alloc_groups"
1197
1198
):
1198
- generate_fixtures_index (
1199
- fixture_output .directory , quiet_mode = True , force_flag = False , disable_infer_format = False
1200
- )
1199
+ # only create fixtures dir if at least one test was filled
1200
+ amount_of_collected_tests = getattr (session , "testscollected" , 0 )
1201
+ if amount_of_collected_tests > 0 :
1202
+ generate_fixtures_index (
1203
+ fixture_output .directory ,
1204
+ quiet_mode = True ,
1205
+ force_flag = False ,
1206
+ disable_infer_format = False ,
1207
+ )
1208
+ else :
1209
+ # nuke the fixtures dir, but only if:
1210
+ # * html output is disabled
1211
+ # and
1212
+ # * no tests were filled
1213
+ html_output_is_enabled = getattr (session .config .option , "htmlpath" , None )
1214
+ if not html_output_is_enabled :
1215
+ shutil .rmtree ("fixtures" )
1201
1216
1202
1217
# Create tarball of the output directory if the output is a tarball.
1203
1218
fixture_output .create_tarball ()
You can’t perform that action at this time.
0 commit comments