Skip to content

Commit

Permalink
Allow non-string keys in assertDictContainsSubset
Browse files Browse the repository at this point in the history
Fixes #54.
  • Loading branch information
boris authored and nicoddemus committed Dec 7, 2024
1 parent cb608b9 commit 5b9414a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Changelog

- Python >=3.9 is now required.

- Allow non-string keys when translating ``assertDictContainsSubset`` (`#54`_).

.. _#54: https://github.com/pytest-dev/unittest2pytest/issues/54


0.4 (2019-06-30)
----------------
Expand Down
10 changes: 5 additions & 5 deletions tests/fixtures/self_assert/assertDictContainsSubset_out.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

class TestDictEqual(TestCase):
def test_simple(self):
assert dict(superset, **{'a: 1'}) == superset
assert {**superset, **{'a: 1'}} == superset

def test_simple_msg(self):
assert dict({'a: 1'}, **subset) == {'a: 1'}, "This is wrong!"
assert {**{'a: 1'}, **subset} == {'a: 1'}, "This is wrong!"

def test_simple_msg2(self):
assert dict({'a: 1'}, **subset) == {'a: 1'}, "This is wrong!"
assert {**{'a: 1'}, **subset} == {'a: 1'}, "This is wrong!"

def test_line_wrapping(self):
assert dict({
assert {**{
'a': 1,
'b': 2,
}, **{'b': 2}) == {
}, **{'b': 2}} == {
'a': 1,
'b': 2,
}, \
Expand Down
2 changes: 1 addition & 1 deletion unittest2pytest/fixes/fix_self_assert.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def get_import_nodes(node):
'assertTupleEqual': partial(CompOp, '=='),
'assertSequenceEqual': SequenceEqual,

'assertDictContainsSubset': partial(DualOp, 'dict(\2, **\1) == \2'),
'assertDictContainsSubset': partial(DualOp, '{**\2, **\1} == \2'),
'assertItemsEqual': partial(DualOp, 'sorted(\1) == sorted(\2)'),

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

0 comments on commit 5b9414a

Please sign in to comment.