[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

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



commit 89efc2b6722c71b009ef3746a613b9fa512f01a8
Author: juga0 <juga@xxxxxxxxxx>
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"



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits