Skip to content

Commit 5b9414a

Browse files
borisnicoddemus
boris
authored andcommitted
Allow non-string keys in assertDictContainsSubset
Fixes #54.
1 parent cb608b9 commit 5b9414a

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

CHANGES.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ Changelog
66

77
- Python >=3.9 is now required.
88

9+
- Allow non-string keys when translating ``assertDictContainsSubset`` (`#54`_).
10+
11+
.. _#54: https://github.com/pytest-dev/unittest2pytest/issues/54
12+
913

1014
0.4 (2019-06-30)
1115
----------------

tests/fixtures/self_assert/assertDictContainsSubset_out.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
class TestDictEqual(TestCase):
44
def test_simple(self):
5-
assert dict(superset, **{'a: 1'}) == superset
5+
assert {**superset, **{'a: 1'}} == superset
66

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

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

1313
def test_line_wrapping(self):
14-
assert dict({
14+
assert {**{
1515
'a': 1,
1616
'b': 2,
17-
}, **{'b': 2}) == {
17+
}, **{'b': 2}} == {
1818
'a': 1,
1919
'b': 2,
2020
}, \

unittest2pytest/fixes/fix_self_assert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def get_import_nodes(node):
275275
'assertTupleEqual': partial(CompOp, '=='),
276276
'assertSequenceEqual': SequenceEqual,
277277

278-
'assertDictContainsSubset': partial(DualOp, 'dict(\2, **\1) == \2'),
278+
'assertDictContainsSubset': partial(DualOp, '{**\2, **\1} == \2'),
279279
'assertItemsEqual': partial(DualOp, 'sorted(\1) == sorted(\2)'),
280280

281281
'assertAlmostEqual': partial(AlmostOp, "==", "<"),

0 commit comments

Comments
 (0)