1414import os
1515
1616import pytest
17-
1817from commoncode .testcase import FileDrivenTesting
18+
1919from formattedcode .output_csv import flatten_scan
2020from scancode .cli_test_utils import run_scan_click
2121from scancode .cli_test_utils import run_scan_plain
22+ from scancode_config import REGEN_TEST_FIXTURES
2223
2324
2425test_env = FileDrivenTesting ()
@@ -38,7 +39,7 @@ def load_scan(json_input):
3839 return scan_results
3940
4041
41- def check_json (result , expected_file , regen = False ):
42+ def check_json (result , expected_file , regen = REGEN_TEST_FIXTURES ):
4243 if regen :
4344 with io .open (expected_file , 'w' , encoding = 'utf-8' ) as reg :
4445 reg .write (json .dumps (result , indent = 4 , separators = (',' , ': ' )))
@@ -49,7 +50,7 @@ def check_json(result, expected_file, regen=False):
4950
5051def check_csvs (result_file , expected_file ,
5152 ignore_keys = ('date' , 'file_type' , 'mime_type' , 'package_uuid' ),
52- regen = False ):
53+ regen = REGEN_TEST_FIXTURES ):
5354 """
5455 Load and compare two CSVs.
5556 `ignore_keys` is a tuple of keys that will be ignored in the comparisons.
@@ -93,7 +94,7 @@ def test_flatten_scan_minimal():
9394 ])
9495 result = list (flatten_scan (scan , headers ))
9596 expected_file = test_env .get_test_loc ('csv/flatten_scan/minimal.json-expected' )
96- check_json (result , expected_file , regen = False )
97+ check_json (result , expected_file , regen = REGEN_TEST_FIXTURES )
9798
9899
99100def test_flatten_scan_can_process_path_with_and_without_leading_slash ():
@@ -119,7 +120,7 @@ def test_can_process_live_scan_for_packages_with_root():
119120 args = ['--package' , test_dir , '--csv' , result_file ]
120121 run_scan_plain (args )
121122 expected_file = test_env .get_test_loc ('csv/packages/expected.csv' )
122- check_csvs (result_file , expected_file , regen = False )
123+ check_csvs (result_file , expected_file , regen = REGEN_TEST_FIXTURES )
123124
124125
125126def test_output_can_handle_non_ascii_paths ():
@@ -234,7 +235,7 @@ def test_can_process_live_scan_with_all_options():
234235 args = ['-clip' , '--email' , '--url' , '--strip-root' , test_dir , '--csv' , result_file ]
235236 run_scan_plain (args )
236237 expected_file = test_env .get_test_loc ('csv/livescan/expected.csv' )
237- check_csvs (result_file , expected_file , regen = False )
238+ check_csvs (result_file , expected_file , regen = REGEN_TEST_FIXTURES )
238239
239240
240241@pytest .mark .scanslow
@@ -244,7 +245,7 @@ def test_can_process_live_scan_for_packages_strip_root():
244245 args = ['--package' , '--strip-root' , test_dir , '--csv' , result_file ]
245246 run_scan_plain (args )
246247 expected_file = test_env .get_test_loc ('csv/packages/expected-no-root.csv' )
247- check_csvs (result_file , expected_file , regen = False )
248+ check_csvs (result_file , expected_file , regen = REGEN_TEST_FIXTURES )
248249
249250
250251@pytest .mark .scanslow
@@ -254,7 +255,7 @@ def test_output_contains_license_expression():
254255 args = ['--from-json' , test_file , '--csv' , result_file ]
255256 run_scan_plain (args )
256257 expected_file = test_env .get_test_loc ('csv/expressions/expected.csv' )
257- check_csvs (result_file , expected_file , regen = False )
258+ check_csvs (result_file , expected_file , regen = REGEN_TEST_FIXTURES )
258259
259260
260261@pytest .mark .scanslow
@@ -264,4 +265,4 @@ def test_output_handles_non_standard_data():
264265 args = ['--from-json' , test_file , '--csv' , result_file ]
265266 run_scan_plain (args )
266267 expected_file = test_env .get_test_loc ('csv/non-standard/identified.csv' )
267- check_csvs (result_file , expected_file , regen = False )
268+ check_csvs (result_file , expected_file , regen = REGEN_TEST_FIXTURES )
0 commit comments