alter unittest to use tmp_path
import pytest
+import pathlib
import os
import io
@@ -12,8 +13,7 @@ from checkov.terraform.runner import Runner as tf_runner
class TestBomOutput:
- def test_csv_output(self):
- tmp_path
+ def test_csv_output(self, tmp_path: pathlib.Path):
test_files_dir = os.path.dirname(os.path.realpath(__file__)) + "/../runner_registry/example_s3_tf"
runner_filter = RunnerFilter(framework=None, checks=None, skip_checks=None)
runner_registry = RunnerRegistry(
@@ -22,12 +22,10 @@ class TestBomOutput:
reports = runner_registry.run(root_folder=test_files_dir)
with patch('sys.stdout', new=io.StringIO()) as captured_output:
- runner_registry.print_iac_bom_reports(output_path="/tmp", scan_reports=reports, output_types=['csv'])
-
+ runner_registry.print_iac_bom_reports(output_path=str(tmp_path), scan_reports=reports, output_types=['csv'])
output = captured_output.getvalue()
-
assert 'Persisting SBOM to' in output
- iac_file_path = '/tmp/results_iac.csv'
+ iac_file_path = tmp_path / 'results_iac.csv'
with open(iac_file_path) as file:
content = file.readlines()
header = content[:1][0]
