diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-05-11 13:52:42 +0100 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-05-11 13:52:42 +0100 |
commit | e5fefead3a643085055e8419f330e5756268013c (patch) | |
tree | 51297ba37b8dcc3031da8829d74894ee13f600ba /morphlib/cachekeycomputer_tests.py | |
parent | 8a02512e83750f6f057b0e0bb21d4d54ee619c10 (diff) | |
download | morph-e5fefead3a643085055e8419f330e5756268013c.tar.gz |
Fix stringifying morphologies to be deterministic
Previously we were stringifying complex values (lists, dicts) by
using whatever Python produces, but different runs and versions of
Python may convert them differently, particularly dicts. We now do
it manually.
Diffstat (limited to 'morphlib/cachekeycomputer_tests.py')
-rw-r--r-- | morphlib/cachekeycomputer_tests.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/morphlib/cachekeycomputer_tests.py b/morphlib/cachekeycomputer_tests.py index 7fc47370..32aef02e 100644 --- a/morphlib/cachekeycomputer_tests.py +++ b/morphlib/cachekeycomputer_tests.py @@ -166,3 +166,17 @@ class CacheKeyComputerTests(unittest.TestCase): old_sha = self.ckc.compute_key(old_artifact) new_sha = self.ckc.compute_key(new_artifact) self.assertEqual(old_sha, new_sha) + + def test_stringifies_string(self): + self.assertEqual(self.ckc._stringify('foo'), 'foo') + + def test_stringifies_integer(self): + self.assertEqual(self.ckc._stringify(12765), '12765') + + def test_stringifies_dict(self): + self.assertEqual(self.ckc._stringify({'foo': 'bar', 'yo': 'foobar' }), + '{foo:bar,yo:foobar}') + + def test_stringifies_list(self): + self.assertEqual(self.ckc._stringify(['foo', 'bar']), '[foo,bar]') + |