Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions simpleaudit/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ def summary(self):

def to_dict(self) -> Dict:
return {
"version": "1.0",
"timestamp": self.timestamp,
"summary": {
"total_scenarios": len(self.results),
Expand Down
22 changes: 22 additions & 0 deletions tests/test_audit_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,28 @@ def test_save_produces_valid_json(self):
finally:
os.unlink(filepath)

def test_saved_json_carries_format_version(self):
"""The export names its format version, as RepeatedExperimentResults does."""
results = AuditResults([_make_audit_result()])
assert results.to_dict()["version"] == "1.0"

with tempfile.NamedTemporaryFile(suffix=".json", delete=False) as f:
filepath = f.name

try:
results.save(filepath)
with open(filepath) as f:
data = json.load(f)
assert data["version"] == "1.0"

# Files written before the key existed still load.
del data["version"]
with open(filepath, "w") as f:
json.dump(data, f)
assert len(AuditResults.load(filepath)) == 1
finally:
os.unlink(filepath)


# --- Plot smoke test ---

Expand Down
Loading