Skip to content

Commit

Permalink
Add support for assertItemsEqual
Browse files Browse the repository at this point in the history
  • Loading branch information
jck authored and htgoebel committed Oct 1, 2019
1 parent 95cfce7 commit 39cdfaa
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
11 changes: 11 additions & 0 deletions tests/fixtures/self_assert/assertItemsEqual_in.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# required-method: assertItemsEqual

class TestItemsEqual(TestCase):
def test_simple(self):
self.assertItemsEqual(a, b)

def test_simple_msg(self):
self.assertItemsEqual(a, b, msg="This is wrong!")

def test_simple_msg2(self):
self.assertItemsEqual(a, b, "This is wrong!")
11 changes: 11 additions & 0 deletions tests/fixtures/self_assert/assertItemsEqual_out.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# required-method: assertItemsEqual

class TestItemsEqual(TestCase):
def test_simple(self):
assert sorted(a) == sorted(b)

def test_simple_msg(self):
assert sorted(a) == sorted(b), "This is wrong!"

def test_simple_msg2(self):
assert sorted(a) == sorted(b), "This is wrong!"
3 changes: 1 addition & 2 deletions unittest2pytest/fixes/fix_self_assert.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,7 @@ def get_import_nodes(node):
'assertSequenceEqual': SequenceEqual,

'assertDictContainsSubset': partial(DualOp, 'dict(\2, **\1) == \2'),
# :todo:
#'assertItemsEqual': '', # unordered sequence specific comparison.
'assertItemsEqual': partial(DualOp, 'sorted(\1) == sorted(\2)'),

'assertAlmostEqual': partial(AlmostOp, "==", "<"),
'assertNotAlmostEqual': partial(AlmostOp, "!=", ">"),
Expand Down

0 comments on commit 39cdfaa

Please sign in to comment.