Skip to content

Commit 07cfdef

Browse files
committed
Test that modified RunData is written and restored.
Ref #61
1 parent 51388b6 commit 07cfdef

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

tests/test_run_data.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,21 @@ def test_run_data(tmpdir, raw_pair_data):
5656
rd.set(alpha=1., name=name)
5757

5858
# Test getting
59-
rd.get("alpha", name=name)
6059
with pytest.raises(ValueError):
6160
rd.get("alpha")
61+
assert rd.get("alpha", name=name) == 1.
6262

6363
# Test read/write of the state
6464
rd.save_config("{}/state.json".format(tmpdir))
65-
old_rd = rd
66-
rd = RunData.create_from("{}/state.json".format(tmpdir))
65+
modified_rd = rd
66+
rd = RunData.create_from(pairs)
67+
assert rd.get("alpha", name=name) != 1.
68+
assert modified_rd.as_dictionary() != rd.as_dictionary()
6769

68-
assert old_rd.as_dictionary() != rd.as_dictionary()
69-
rd.set(alpha=1., name=name)
7070
# Confirm that the restored data is the same as the original.
71-
assert old_rd.as_dictionary() == rd.as_dictionary()
71+
rd = RunData.create_from("{}/state.json".format(tmpdir))
72+
assert rd.get("alpha", name=name) == 1.
73+
assert modified_rd.as_dictionary() == rd.as_dictionary()
7274

7375
with tempfile.NamedTemporaryFile(suffix='.json', mode='w') as tmp:
7476
test_data = raw_pair_data.copy()

0 commit comments

Comments
 (0)