[tor-commits] [sbws/master] fix: tests: Test state file consistency

juga at torproject.org juga at torproject.org
Tue Apr 14 13:54:36 UTC 2020


commit 89efc2b6722c71b009ef3746a613b9fa512f01a8
Author: juga0 <juga at riseup.net>
Date:   Sat Mar 14 17:02:43 2020 +0000

    fix: tests: Test state file consistency
    
    Test that two different instances of state don't overwrite each other.
    This test don't past in this commit, will pass in the next bugfix.
    
    Bugfix v0.7.0, which claimed 100% test coverage on state.
---
 tests/unit/util/test_state.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tests/unit/util/test_state.py b/tests/unit/util/test_state.py
index dd23d1a..2443049 100644
--- a/tests/unit/util/test_state.py
+++ b/tests/unit/util/test_state.py
@@ -117,3 +117,12 @@ def test_state_iter(tmpdir):
     for key in d:
         state[key] = d[key]
     assert set([key for key in state]) == set(d)
+
+
+def test_two_instances(tmpdir):
+    """Test that 2 different intances don't overwrite each other"""
+    s1 = State(os.path.join(str(tmpdir), 'state.dat'))
+    s2 = State(os.path.join(str(tmpdir), 'state.dat'))
+    s1["x"] = "foo"
+    s2["y"] = "bar"
+    assert s2["x"] == "foo"





More information about the tor-commits mailing list