From d312edb857cfc6955b0f164cce3f38541cec4481 Mon Sep 17 00:00:00 2001 From: boris Date: Mon, 31 May 2021 18:57:50 -0400 Subject: [PATCH] Allow non-string keys in assertDictContainsSubset --- .../self_assert/assertDictContainsSubset_out.py | 10 +++++----- unittest2pytest/fixes/fix_self_assert.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/fixtures/self_assert/assertDictContainsSubset_out.py b/tests/fixtures/self_assert/assertDictContainsSubset_out.py index a9415f5..07e7f51 100644 --- a/tests/fixtures/self_assert/assertDictContainsSubset_out.py +++ b/tests/fixtures/self_assert/assertDictContainsSubset_out.py @@ -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, }, \ diff --git a/unittest2pytest/fixes/fix_self_assert.py b/unittest2pytest/fixes/fix_self_assert.py index 62326ad..0e96a9f 100644 --- a/unittest2pytest/fixes/fix_self_assert.py +++ b/unittest2pytest/fixes/fix_self_assert.py @@ -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, "==", "<"),