Skip to content

Commit

Permalink
test: fix unittest2pytest brokenness
Browse files Browse the repository at this point in the history
unittest2pytest created syntax errors, reported here:
pytest-dev/unittest2pytest#51

This commit fixes them back.
  • Loading branch information
nedbat committed Jan 31, 2021
1 parent 843de4e commit 6e93714
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
21 changes: 12 additions & 9 deletions tests/test_backward.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@

from coverage.backunittest import TestCase
from coverage.backward import iitems, binary_bytes, bytes_to_ints
"""Tests of things from backward.py."""
deftest_iitems(self):
d = {'a': 1, 'b': 2, 'c': 3}
items = [('a', 1), ('b', 2), ('c', 3)]
self.assertCountEqual(list(iitems(d)), items)

class BackwardTest(TestCase):
"""Tests of things from backward.py."""

def test_iitems(self):
d = {'a': 1, 'b': 2, 'c': 3}
items = [('a', 1), ('b', 2), ('c', 3)]
self.assertCountEqual(list(iitems(d)), items)

def test_binary_bytes(self):
byte_values = [0, 255, 17, 23, 42, 57]
bb = binary_bytes(byte_values)
assert len(bb) == len(byte_values)
assert byte_values == list(bytes_to_ints(bb))
byte_values = [0, 255, 17, 23, 42, 57]
bb = binary_bytes(byte_values)
assert len(bb) == len(byte_values)
assert byte_values == list(bytes_to_ints(bb))
17 changes: 9 additions & 8 deletions tests/test_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ def test_xdist_sys_path_nuttiness_is_fixed():
assert os.environ.get('PYTHONPATH') is None


"""Tests of helper methods on `backunittest.TestCase`."""
deftest_assert_count_equal(self):
self.assertCountEqual(set(), set())
self.assertCountEqual({1,2,3}, {3,1,2})
with pytest.raises(AssertionError):
self.assertCountEqual({1,2,3}, set())
withpytest.raises(AssertionError):
self.assertCountEqual({1,2,3}, {4,5,6})
class TestingTest(TestCase):
"""Tests of helper methods on `backunittest.TestCase`."""

def test_assert_count_equal(self):
self.assertCountEqual(set(), set())
with pytest.raises(AssertionError):
self.assertCountEqual({1,2,3}, set())
with pytest.raises(AssertionError):
self.assertCountEqual({1,2,3}, {4,5,6})


class CoverageTestTest(CoverageTest):
Expand Down

0 comments on commit 6e93714

Please sign in to comment.