Test for encodestream

This commit is contained in:
Tony Garnock-Jones 2018-11-13 10:48:40 +00:00
parent 9762ad4bfb
commit eb090bea4b
1 changed files with 13 additions and 0 deletions

View File

@ -169,3 +169,16 @@ class CodecTests(unittest.TestCase):
0xE2, 0x7A, "first-name", 0x59, "Elizabeth",
0xE2, 0x77, "surname", 0x59, "Blackwell"),
nondeterministic = True)
def test_iterator_stream(self):
d = {u'a': 1, u'b': 2, u'c': 3}
r = r'2c(c2516.1.){3}3c'
if hasattr(d, 'iteritems'):
# python 2
bs = _e(d.iteritems())
self.assertRegexpMatches(_hex(bs), r)
else:
# python 3
bs = _e(d.items())
self.assertRegex(_hex(bs), r)
self.assertEqual(sorted(_d(bs)), [(u'a', 1), (u'b', 2), (u'c', 3)])