test_backward.py 806 B

1234567891011121314151617181920212223
  1. # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
  2. # For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt
  3. """Tests that our version shims in backward.py are working."""
  4. from coverage.backunittest import TestCase
  5. from coverage.backward import iitems, binary_bytes, bytes_to_ints
  6. class BackwardTest(TestCase):
  7. """Tests of things from backward.py."""
  8. def test_iitems(self):
  9. d = {'a': 1, 'b': 2, 'c': 3}
  10. items = [('a', 1), ('b', 2), ('c', 3)]
  11. self.assertCountEqual(list(iitems(d)), items)
  12. def test_binary_bytes(self):
  13. byte_values = [0, 255, 17, 23, 42, 57]
  14. bb = binary_bytes(byte_values)
  15. self.assertEqual(len(bb), len(byte_values))
  16. self.assertEqual(byte_values, list(bytes_to_ints(bb)))