11from ..contain_subset import contain_subset
22
33plain_object = {
4- 'a' :'b' ,
5- 'c' :'d'
4+ 'a' : 'b' ,
5+ 'c' : 'd'
66}
77
88complex_object = {
1616 }
1717}
1818
19+
1920def test_plain_object_should_pass_for_smaller_object ():
2021 assert contain_subset ({'a' : 'b' }, plain_object )
2122
2223
2324def test_plain_object_should_pass_for_same_object ():
2425 assert contain_subset ({
25- 'a' :'b' ,
26- 'c' :'d'
26+ 'a' : 'b' ,
27+ 'c' : 'd'
2728 }, plain_object )
2829
2930
3031def test_plain_object_should_reject_for_similar_object ():
3132 assert not contain_subset ({
32- 'a' :'notB' ,
33- 'c' :'d'
33+ 'a' : 'notB' ,
34+ 'c' : 'd'
3435 }, plain_object )
3536
3637
3738def test_complex_object_should_pass_for_smaller_object ():
3839 assert contain_subset ({
39- 'a' :'b' ,
40+ 'a' : 'b' ,
4041 'e' : {
41- 'foo' :'bar'
42+ 'foo' : 'bar'
4243 }
4344 }, complex_object )
4445
4546
4647def test_complex_object_should_pass_for_smaller_object_other ():
4748 assert contain_subset ({
4849 'e' : {
49- 'foo' :'bar' ,
50- 'baz' :{
50+ 'foo' : 'bar' ,
51+ 'baz' : {
5152 'qux' : 'quux'
5253 }
5354 }
@@ -70,8 +71,8 @@ def test_complex_object_should_pass_for_same_object():
7071def test_complex_object_should_reject_for_similar_object ():
7172 assert not contain_subset ({
7273 'e' : {
73- 'foo' :'bar' ,
74- 'baz' :{
74+ 'foo' : 'bar' ,
75+ 'baz' : {
7576 'qux' : 'notAQuux'
7677 }
7778 }
@@ -80,47 +81,47 @@ def test_complex_object_should_reject_for_similar_object():
8081
8182def test_circular_objects_should_contain_subdocument ():
8283 obj = {}
83- obj ['arr' ] = [obj ,obj ]
84+ obj ['arr' ] = [obj , obj ]
8485 obj ['arr' ].append (obj ['arr' ])
8586 obj ['obj' ] = obj
8687
8788 assert contain_subset ({
88- 'arr' : [
89- {'arr' : []},
89+ 'arr' : [
90+ {'arr' : []},
91+ {'arr' : []},
92+ [
9093 {'arr' : []},
91- [
92- {'arr' : []},
93- {'arr' : []}
94- ]
94+ {'arr' : []}
9595 ]
96- }, obj )
96+ ]
97+ }, obj )
9798
9899
99100def test_circular_objects_should_not_contain_similardocument ():
100101 obj = {}
101- obj ['arr' ] = [obj ,obj ]
102+ obj ['arr' ] = [obj , obj ]
102103 obj ['arr' ].append (obj ['arr' ])
103104 obj ['obj' ] = obj
104105
105106 assert not contain_subset ({
106- 'arr' : [
107- {'arr' : ['just random field' ]},
107+ 'arr' : [
108+ {'arr' : ['just random field' ]},
109+ {'arr' : []},
110+ [
108111 {'arr' : []},
109- [
110- {'arr' : []},
111- {'arr' : []}
112- ]
112+ {'arr' : []}
113113 ]
114- }, obj )
114+ ]
115+ }, obj )
115116
116117
117118def test_should_contain_others ():
118119 obj = {
119- 'elems' : [{'a' :'b' , 'c' :'d' , 'e' :'f' }, {'g' :'h' }]
120+ 'elems' : [{'a' : 'b' , 'c' : 'd' , 'e' : 'f' }, {'g' : 'h' }]
120121 }
121122 assert contain_subset ({
122123 'elems' : [{
123- 'g' :'h'
124- },{'a' :'b' ,'e' :'f' }
124+ 'g' : 'h'
125+ }, {'a' : 'b' , 'e' : 'f' }
125126 ]
126127 }, obj )
0 commit comments