Skip to content

Commit

Permalink
Update test_export_scan_test_suite_results_to_json
Browse files Browse the repository at this point in the history
  • Loading branch information
henchaves committed Dec 17, 2024
1 parent 4995527 commit 598c6ea
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions tests/scan/test_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,27 +287,29 @@ def test_min_slice_size(titanic_model, titanic_dataset):
"filename",
[(None), ("scan_report.json")],
)
def test_export_scan_results_to_json(filename, request):
@pytest.mark.slow
def test_export_scan_test_suite_results_to_json(filename, request):
DATASET_NAME = "diabetes_dataset_with_target"
MODEL_NAME = "linear_regression_diabetes"

dataset = request.getfixturevalue(DATASET_NAME)
model = request.getfixturevalue(MODEL_NAME)

scanner = Scanner()
report = scanner.analyze(model, dataset)
scan_results = scanner.analyze(model, dataset)
test_suite_results = scan_results.generate_test_suite().run()

if filename:
with tempfile.TemporaryDirectory() as tmpdir:
dest = Path(tmpdir).joinpath(filename)
report.to_json(dest)
test_suite_results.to_json(dest)
assert dest.exists()
assert dest.is_file()
json_report = dest.read_text(encoding="utf-8")
test_results_json = dest.read_text(encoding="utf-8")

else:
json_report = report.to_json()
assert json_report is not None
test_results_json = test_suite_results.to_json()
assert test_results_json is not None

assert json_report.startswith("{")
assert json_report.strip().endswith("}")
assert test_results_json.startswith("{")
assert test_results_json.strip().endswith("}")

0 comments on commit 598c6ea

Please sign in to comment.