diff --git a/tests/common/test_strings.py b/tests/common/test_strings.py index c6593fe..9892b1a 100644 --- a/tests/common/test_strings.py +++ b/tests/common/test_strings.py @@ -1,5 +1,7 @@ from __future__ import unicode_literals +import copy +import pickle import sys import pytest @@ -40,6 +42,13 @@ def test_contains(self): assert "world" not in LazyString(str.upper, "hello world") assert "WORLD" in LazyString(str.upper, "hello world") + def test_copy_deepcopy_and_pickle(self): + string = LazyString(str.upper, "hello world") + + assert str(copy.copy(string)) == "HELLO WORLD" + assert str(copy.deepcopy(string)) == "HELLO WORLD" + assert str(pickle.loads(pickle.dumps(string))) == "HELLO WORLD" + def test_eq(self): assert LazyString(str.upper, "hello world") == "HELLO WORLD" assert "HELLO WORLD" == LazyString(str.upper, "hello world") diff --git a/transifex/common/strings.py b/transifex/common/strings.py index daa70a0..447212b 100644 --- a/transifex/common/strings.py +++ b/transifex/common/strings.py @@ -112,6 +112,7 @@ def lazy_str_meta(name, bases, dct): "__init__", "__doc__", "__reduce__", + "__getstate__", "__new__", "__str__", "__dir__",