-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add fixture for assertDictContainsSubset.
Thanks to Ryan T. Dean for providing the idea. Closes #22.
- Loading branch information
Showing
3 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# required-method: assertDictContainsSubset | ||
|
||
class TestDictEqual(TestCase): | ||
def test_simple(self): | ||
self.assertDictContainsSubset({'a: 1'}, superset) | ||
|
||
def test_simple_msg(self): | ||
self.assertDictContainsSubset(subset, {'a: 1'}, msg="This is wrong!") | ||
|
||
def test_simple_msg2(self): | ||
self.assertDictContainsSubset(subset, {'a: 1'}, "This is wrong!") | ||
|
||
def test_line_wrapping(self): | ||
self.assertDictContainsSubset( | ||
{'b': 2}, | ||
{ | ||
'a': 1, | ||
'b': 2, | ||
}, | ||
"This is wrong!", | ||
) |
21 changes: 21 additions & 0 deletions
21
tests/fixtures/self_assert/assertDictContainsSubset_out.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# required-method: assertDictContainsSubset | ||
|
||
class TestDictEqual(TestCase): | ||
def test_simple(self): | ||
assert dict({'a: 1'}, **superset) == superset | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
def test_simple_msg(self): | ||
assert dict(subset, **{'a: 1'}) == {'a: 1'}, "This is wrong!" | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
def test_simple_msg2(self): | ||
assert dict(subset, **{'a: 1'}) == {'a: 1'}, "This is wrong!" | ||
|
||
def test_line_wrapping(self): | ||
assert dict({'b': 2}, **{ | ||
'a': 1, | ||
'b': 2, | ||
}) == { | ||
'a': 1, | ||
'b': 2, | ||
}, \ | ||
"This is wrong!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,7 +88,7 @@ def fill_template(template, *args): | |
p.prefix = '' | ||
else: | ||
p = Name(p) | ||
kids.append(p) | ||
kids.append(p.clone()) | ||
return kids | ||
|
||
def DualOp(template, first, second, kws): | ||
|
@@ -273,8 +273,8 @@ def get_import_nodes(node): | |
'assertTupleEqual': partial(CompOp, '=='), | ||
'assertSequenceEqual': SequenceEqual, | ||
|
||
'assertDictContainsSubset': partial(DualOp, 'dict(\1, **\2) == \2'), | ||
This comment has been minimized.
Sorry, something went wrong.
RonnyPfannschmidt
Member
|
||
# :todo: | ||
#'assertDictContainsSubset': '', | ||
#'assertItemsEqual': '', # unordered sequence specific comparison. | ||
|
||
'assertAlmostEqual': partial(AlmostOp, "==", "<"), | ||
|
this code needs to read
dict(superset, **{'a: 1'}) == superset)