diff --git a/strobe/python/Makefile b/strobe/python/Makefile index 31985a5..06fcf99 100644 --- a/strobe/python/Makefile +++ b/strobe/python/Makefile @@ -57,6 +57,9 @@ shakat: $(SHAKAT) shavs: shakat shamont @echo "All known-answer tests passed" +test-python: + python -m unittest Strobe.Test.copy + test: shavs clean: diff --git a/strobe/python/Strobe/Strobe.py b/strobe/python/Strobe/Strobe.py index 7e2f169..85671e4 100644 --- a/strobe/python/Strobe/Strobe.py +++ b/strobe/python/Strobe/Strobe.py @@ -42,6 +42,7 @@ class Strobe(object): (copy_of.R,copy_of.pos,copy_of.posbegin,copy_of.I0, copy_of.F.copy()) self.st = bytearray(copy_of.st) + self.initialized = True def copy(self): return Strobe(None,copy_of=self) def deepcopy(self): return self.copy() diff --git a/strobe/python/Strobe/Test/copy.py b/strobe/python/Strobe/Test/copy.py new file mode 100644 index 0000000..92b388a --- /dev/null +++ b/strobe/python/Strobe/Test/copy.py @@ -0,0 +1,21 @@ +# Test to make sure copy works. + +import unittest + +from Strobe.Strobe import Strobe + +class TestCopy(unittest.TestCase): + def test_copy(self): + a = Strobe(b'foo') + b = Strobe(b'foo') + + msg = a.send_enc(b'atest') + self.assertEqual(b'atest', b.recv_enc(msg)) + + c = b.copy() + + msg = a.send_enc(b'anothertest') + + # that both the original and copy work + self.assertEqual(b'anothertest', b.recv_enc(msg)) + self.assertEqual(b'anothertest', c.recv_enc(msg))