diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2016-12-13 20:07:11 +1300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-12-14 09:54:48 +0000 |
commit | bbbb2a53d5decf3b613a92c4ff77c84bfc5d4903 (patch) | |
tree | ffa0c470564c027522bd87c02df8938bd900e671 /lib/bb/tests/data.py | |
parent | 5cfbb60833e7b12d698c1c2970c17ccf2a4971bf (diff) | |
download | bitbake-bbbb2a53d5decf3b613a92c4ff77c84bfc5d4903.tar.gz |
data_smart: support serialisation
The COW object used within VariableHistory can't be serialised itself,
but we can convert it to a dict when serializing and then back when
deserialising. This finally allows DataSmart objects to be serialized.
NOTE: "serialisation" here means pickling, not over XMLRPC or any other
transport.
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/tests/data.py')
-rw-r--r-- | lib/bb/tests/data.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/bb/tests/data.py b/lib/bb/tests/data.py index a17245f90..ba30d1280 100644 --- a/lib/bb/tests/data.py +++ b/lib/bb/tests/data.py @@ -446,6 +446,29 @@ class Contains(unittest.TestCase): self.assertFalse(bb.utils.contains_any("SOMEFLAG", "x y z", True, False, self.d)) +class Serialize(unittest.TestCase): + + def test_serialize(self): + import tempfile + import pickle + d = bb.data.init() + d.enableTracking() + d.setVar('HELLO', 'world') + d.setVarFlag('HELLO', 'other', 'planet') + with tempfile.NamedTemporaryFile(delete=False) as tmpfile: + tmpfilename = tmpfile.name + pickle.dump(d, tmpfile) + + with open(tmpfilename, 'rb') as f: + newd = pickle.load(f) + + os.remove(tmpfilename) + + self.assertEqual(d, newd) + self.assertEqual(newd.getVar('HELLO', True), 'world') + self.assertEqual(newd.getVarFlag('HELLO', 'other'), 'planet') + + class Remote(unittest.TestCase): def test_remote(self): class TestConnector: |