How to use assertDictEqual method in autotest

Best Python code snippet using autotest_python

test_diff.py

Source:test_diff.py Github

copy

Full Screen

...7 df1 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]}, 8 index=['w','x','y'])9 df2 = pd.DataFrame({'a': [1,2,9], 'b': [4,5,6]},10 index=['w','x','y'])11 self.assertDictEqual(diff_nodes(df1, df2),12 {'add': {},13 'del': {}, 14 'mod': {'y': {'a': 9, 'b': 6}}})15 def test_mod_row_int_ind(self):16 df1 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]}, 17 index=[0,1,2])18 df2 = pd.DataFrame({'a': [1,2,9], 'b': [4,5,6]},19 index=[0,1,2])20 self.assertDictEqual(diff_nodes(df1, df2),21 {'add': {},22 'del': {}, 23 'mod': {2: {'a': 9, 'b': 6}}})24 def test_add_row(self):25 df1 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]}, 26 index=['w','x','y'])27 df2 = pd.DataFrame({'a': [1,2,3,4], 'b': [4,5,6,7]},28 index=['w','x','y','z'])29 self.assertDictEqual(diff_nodes(df1, df2),30 {'add': {'z': {'a': 4, 'b': 7}},31 'del': {}, 32 'mod': {}})33 def test_add_row_int_ind(self):34 df1 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]}, 35 index=[0,1,2])36 df2 = pd.DataFrame({'a': [1,2,3,4], 'b': [4,5,6,7]},37 index=[0,1,2,3])38 self.assertDictEqual(diff_nodes(df1, df2),39 {'add': {3: {'a': 4, 'b': 7}},40 'del': {}, 41 'mod': {}})42 def test_del_row(self):43 df1 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]}, 44 index=['w','x','y'])45 df2 = pd.DataFrame({'a': [1,3], 'b': [4,6]},46 index=['w','y'])47 self.assertDictEqual(diff_nodes(df1, df2),48 {'add': {},49 'del': {'x': None},50 'mod': {}})51 def test_ren_row(self):52 df1 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]}, 53 index=['w','x','y'])54 df2 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]},55 index=['w','x','z'])56 self.assertDictEqual(diff_nodes(df1, df2),57 {'add': {'z': {'a': 3, 'b': 6}},58 'del': {'y': None},59 'mod': {}})60 def test_ren_row_int_ind(self):61 df1 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]}, 62 index=[0,1,2])63 df2 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]},64 index=[0,1,3])65 self.assertDictEqual(diff_nodes(df1, df2),66 {'add': {3: {'a': 3, 'b': 6}},67 'del': {2: None},68 'mod': {}})69 def test_add_col(self):70 df1 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]}, 71 index=['w','x','y'])72 df2 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6],73 'c': ['p','q','r']},74 index=['w','x','y'])75 self.assertDictEqual(diff_nodes(df1, df2),76 {'add': {},77 'mod': {'w': {'a': 1, 'b': 4, 'c': 'p'},78 'x': {'a': 2, 'b': 5, 'c': 'q'},79 'y': {'a': 3, 'b': 6, 'c': 'r'}},80 'del': {}})81 def test_del_col(self):82 df1 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]}, 83 index=['w','x','y'])84 df2 = pd.DataFrame({'a': [1,2,3]},85 index=['w','x','y'])86 self.assertDictEqual(diff_nodes(df1, df2),87 {'add': {},88 'mod': {'w': {'a': 1}, 'x': {'a': 2}, 'y': {'a': 3}},89 'del': {}})90 def test_ren_col(self):91 df1 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]}, 92 index=['w','x','y'])93 df2 = pd.DataFrame({'a': [1,2,3], 'c': [4,5,6]},94 index=['w','x','y'])95 self.assertDictEqual(diff_nodes(df1, df2),96 {'add': {},97 'mod': {'w': {'a': 1, 'c': 4},98 'x': {'a': 2, 'c': 5},99 'y': {'a': 3, 'c': 6}},100 'del': {}})101 def test_mod_row_add_row(self):102 df1 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]}, 103 index=['w','x','y'])104 df2 = pd.DataFrame({'a': [1,2,9,4], 'b': [4,5,6,7]},105 index=['w','x','y','z'])106 self.assertDictEqual(diff_nodes(df1, df2),107 {'add': {'z': {'a': 4, 'b': 7}},108 'mod': {'y': {'a': 9, 'b': 6}},109 'del': {}})110 111 def test_mod_row_del_row(self):112 df1 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]}, 113 index=['w','x','y'])114 df2 = pd.DataFrame({'a': [1,9], 'b': [4,6]},115 index=['w','y'])116 self.assertDictEqual(diff_nodes(df1, df2),117 {'add': {},118 'mod': {'y': {'a': 9, 'b': 6}},119 'del': {'x': None}})120 def test_mod_row_ren_row(self):121 df1 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]}, 122 index=['w','x','y'])123 df2 = pd.DataFrame({'a': [1,9,3], 'b': [4,5,6]},124 index=['w','x','z'])125 self.assertDictEqual(diff_nodes(df1, df2),126 {'add': {'z': {'a': 3, 'b': 6}},127 'mod': {'x': {'a': 9, 'b': 5}},128 'del': {'y': None}})129 def test_mod_row_add_col(self):130 df1 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]}, 131 index=['w','x','y'])132 df2 = pd.DataFrame({'a': [1,2,9], 'b': [4,5,6], 'c': [7,8,9]},133 index=['w','x','y'])134 self.assertDictEqual(diff_nodes(df1, df2),135 {'add': {},136 'mod': {'w': {'a': 1, 'b': 4, 'c': 7},137 'x': {'a': 2, 'b': 5, 'c': 8},138 'y': {'a': 9, 'b': 6, 'c': 9}},139 'del': {}}) 140 def test_mod_row_del_col(self):141 df1 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]}, 142 index=['w','x','y'])143 df2 = pd.DataFrame({'a': [1,2,4]},144 index=['w','x','y'])145 self.assertDictEqual(diff_nodes(df1, df2),146 {'add': {},147 'mod': {'w': {'a': 1},148 'x': {'a': 2},149 'y': {'a': 4}},150 'del': {}}) 151 def test_mod_row_ren_col(self):152 df1 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]}, 153 index=['w','x','y'])154 df2 = pd.DataFrame({'a': [1,2,3], 'c': [5,5,6]},155 index=['w','x','y'])156 self.assertDictEqual(diff_nodes(df1, df2),157 {'add': {},158 'mod': {'w': {'a': 1, 'c': 5},159 'x': {'a': 2, 'c': 5},160 'y': {'a': 3, 'c': 6}},161 'del': {}}) 162 def test_del_row_add_col(self):163 df1 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]}, 164 index=['w','x','y'])165 df2 = pd.DataFrame({'a': [1,3], 'b': [4,6], 'c': [7,9]},166 index=['w','y'])167 self.assertDictEqual(diff_nodes(df1, df2),168 {'add': {},169 'mod': {'w': {'a': 1, 'b': 4, 'c': 7},170 'y': {'a': 3, 'b': 6, 'c': 9}},171 'del': {'x': None}}) 172 def test_del_row_del_col(self):173 df1 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6], 'c': [7,8,9]}, 174 index=['w','x','y'])175 df2 = pd.DataFrame({'a': [1,3], 'b': [4,6]},176 index=['w','y'])177 self.assertDictEqual(diff_nodes(df1, df2),178 {'add': {},179 'mod': {'w': {'a': 1, 'b': 4},180 'y': {'a': 3, 'b': 6}},181 'del': {'x': None}}) 182 def test_del_row_ren_col(self):183 df1 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6], 'c': [7,8,9]}, 184 index=['w','x','y'])185 df2 = pd.DataFrame({'a': [1,3], 'b': [4,6], 'd': [7,9]},186 index=['w','y'])187 self.assertDictEqual(diff_nodes(df1, df2),188 {'add': {},189 'mod': {'w': {'a': 1, 'b': 4, 'd': 7},190 'y': {'a': 3, 'b': 6, 'd': 9}},191 'del': {'x': None}}) 192 def test_ren_row_add_col(self):193 df1 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]}, 194 index=['w','x','y'])195 df2 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6], 'c': [7,8,9]},196 index=['w','x','z'])197 self.assertDictEqual(diff_nodes(df1, df2),198 {'add': {'z': {'a': 3, 'b': 6, 'c': 9}},199 'mod': {'w': {'a': 1, 'b': 4, 'c': 7},200 'x': {'a': 2, 'b': 5, 'c': 8}},201 'del': {'y': None}}) 202 203 def test_ren_row_del_col(self):204 df1 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6], 'c': [7,8,9]}, 205 index=['w','x','y'])206 df2 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]},207 index=['w','x','z'])208 self.assertDictEqual(diff_nodes(df1, df2),209 {'add': {'z': {'a': 3, 'b': 6}},210 'mod': {'w': {'a': 1, 'b': 4},211 'x': {'a': 2, 'b': 5}},212 'del': {'y': None}}) 213 def test_ren_row_ren_col(self):214 df1 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6], 'c': [7,8,9]}, 215 index=['w','x','y'])216 df2 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6], 'd': [7,8,9]},217 index=['w','x','z'])218 self.assertDictEqual(diff_nodes(df1, df2),219 {'add': {'z': {'a': 3, 'b': 6, 'd': 9}},220 'mod': {'w': {'a': 1, 'b': 4, 'd': 7},221 'x': {'a': 2, 'b': 5, 'd': 8}},222 'del': {'y': None}}) 223if __name__ == '__main__':...

Full Screen

Full Screen

test_example_data.py

Source:test_example_data.py Github

copy

Full Screen

2from app.modules.example_data import FilterableDict, ExampleUser3class TestCreateFilterableDict(unittest.TestCase):4 def test_empty_dict(self):5 f = FilterableDict()6 self.assertDictEqual(f.get(), {})7 self.assertDictEqual(f.set(), {})8 def test_commons_only(self):9 f = FilterableDict(commons={'apple': 1})10 self.assertDictEqual(f.get(), {'apple': 1})11 self.assertDictEqual(f.set(), {'apple': 1})12 def test_getters_only(self):13 f = FilterableDict(getters={'banana': 2})14 self.assertDictEqual(f.get(), {'banana': 2})15 self.assertDictEqual(f.set(), {})16 def test_setters_only(self):17 f = FilterableDict(setters={'orange': 3})18 self.assertDictEqual(f.get(), {})19 self.assertDictEqual(f.set(), {'orange': 3})20 def test_all_type_only(self):21 f = FilterableDict(commons={'apple': 1},22 getters={'banana': 2},23 setters={'orange': 3})24 self.assertDictEqual(f.get(), {'apple': 1, 'banana': 2})25 self.assertDictEqual(f.set(), {'apple': 1, 'orange': 3})26class TestPreFilledFilterableDict(unittest.TestCase):27 def setUp(self):28 self.f = FilterableDict(commons={'apple': 1, 'cacao': 11, 'lemon': {'small': 4, 'big': 5}},29 getters={'banana': 2, 'peach': 22},30 setters={'orange': 3, 'plum': 33})31 def test_get_elements_by_name(self):32 self.assertEqual(self.f['apple'], 1)33 self.assertEqual(self.f['cacao'], 11)34 self.assertEqual(self.f['banana'], 2)35 self.assertEqual(self.f['peach'], 22)36 self.assertEqual(self.f['orange'], 3)37 self.assertEqual(self.f['plum'], 33)38 self.assertEqual(self.f['lemon'], {'small': 4, 'big': 5})39 def test_filter_commons(self):40 self.assertDictEqual(self.f.get(['apple']), {'apple': 1})41 self.assertDictEqual(self.f.get(['lemon']), {'lemon': {'small': 4, 'big': 5}})42 self.assertDictEqual(self.f.set(['apple']), {'apple': 1})43 self.assertDictEqual(self.f.set(['lemon']), {'lemon': {'small': 4, 'big': 5}})44 def test_filter_getters(self):45 self.assertDictEqual(self.f.get(['peach']), {'peach': 22})46 self.assertDictEqual(self.f.set(['peach']), {})47 def test_filter_setters(self):48 self.assertDictEqual(self.f.get(['plum']), {})49 self.assertDictEqual(self.f.set(['plum']), {'plum': 33})50 def test_filter_multiple_elements(self):51 self.assertDictEqual(self.f.get(['cacao', 'banana', 'orange', 'lemon']),52 {'cacao': 11, 'banana': 2, 'lemon': {'small': 4, 'big': 5}})53 self.assertDictEqual(self.f.set(['cacao', 'banana', 'orange', 'lemon']),54 {'cacao': 11, 'orange': 3, 'lemon': {'small': 4, 'big': 5}})55 def test_change(self):56 self.assertDictEqual(self.f.get(change={'cacao': 110, 'banana': 20, 'lemon': {'big': 50}}),57 {'apple': 1, 'cacao': 110, 'banana': 20, 'peach': 22, 'lemon': {'small': 4, 'big': 50}})58 self.assertDictEqual(self.f.set(change={'cacao': 110, 'orange': 30, 'lemon': {'big': 50}}),59 {'apple': 1, 'cacao': 110, 'orange': 30, 'plum': 33, 'lemon': {'small': 4, 'big': 50}})60 def test_change_in_another_type(self):61 self.assertDictEqual(self.f.get(change={'orange': 330}),62 {'apple': 1, 'cacao': 11, 'banana': 2, 'peach': 22, 'orange': 330,63 'lemon': {'small': 4, 'big': 5}})64 self.assertDictEqual(self.f.set(change={'banana': 20}),65 {'apple': 1, 'cacao': 11, 'orange': 3, 'plum': 33, 'banana': 20,66 'lemon': {'small': 4, 'big': 5}})67 def test_change_a_filtered_field(self):68 self.assertDictEqual(self.f.get(['cacao', 'banana', 'orange'], change={'cacao': 110}),69 {'cacao': 110, 'banana': 2})70 self.assertDictEqual(self.f.get(['cacao', 'lemon'], change={'lemon': {'big': 50}}),71 {'cacao': 11, 'lemon': {'small': 4, 'big': 50}})72 self.assertDictEqual(self.f.set(['cacao', 'banana', 'orange'], change={'cacao': 110}),73 {'cacao': 110, 'orange': 3})74 self.assertDictEqual(self.f.set(['cacao', 'lemon'], change={'lemon': {'big': 50}}),75 {'cacao': 11, 'lemon': {'small': 4, 'big': 50}})76 def test_change_an_out_filtered_field(self):77 self.assertDictEqual(self.f.get(['cacao', 'banana', 'orange'], change={'peach': 220}),78 {'cacao': 11, 'banana': 2})79 self.assertDictEqual(self.f.set(['cacao', 'banana', 'orange'], change={'plum': 330}),80 {'cacao': 11, 'orange': 3})81class TestExampleUser(unittest.TestCase):82 def setUp(self):83 self.u = ExampleUser(commons={'username': 'apple', 'email': 'orange'},84 setters={'password': 'banana'})85 def test_login(self):86 self.assertDictEqual(self.u.login(),87 {'username': 'apple', 'password': 'banana', 'remember': False})88 def test_login_with_overridden_username(self):89 self.assertDictEqual(self.u.login(username='new_apple'),90 {'username': 'new_apple', 'password': 'banana', 'remember': False})91 def test_login_with_overridden_password(self):92 self.assertDictEqual(self.u.login(password='new_banana'),93 {'username': 'apple', 'password': 'new_banana', 'remember': False})94 def test_login_with_overridden_username_and_password(self):95 self.assertDictEqual(self.u.login(username='new_apple', password='new_banana'),96 {'username': 'new_apple', 'password': 'new_banana', 'remember': False})97 def test_login_with_overridden_remember(self):98 self.assertDictEqual(self.u.login(remember=True),...

Full Screen

Full Screen

scopes_test.py

Source:scopes_test.py Github

copy

Full Screen

...33 key_op = (func1.__module__, func1.__name__)34 current_scope = {key_op: func1_kwargs.copy()}35 with self.test_session():36 with scopes.arg_scope([func1], a=1, b=None, c=[1]) as scope:37 self.assertDictEqual(scope, current_scope)38 def testCurrentArgScopeNested(self):39 func1_kwargs = {'a': 1, 'b': None, 'c': [1]}40 func2_kwargs = {'b': 2, 'd': [2]}41 key = lambda f: (f.__module__, f.__name__)42 current_scope = {key(func1): func1_kwargs.copy(),43 key(func2): func2_kwargs.copy()}44 with self.test_session():45 with scopes.arg_scope([func1], a=1, b=None, c=[1]):46 with scopes.arg_scope([func2], b=2, d=[2]) as scope:47 self.assertDictEqual(scope, current_scope)48 def testReuseArgScope(self):49 func1_kwargs = {'a': 1, 'b': None, 'c': [1]}50 key_op = (func1.__module__, func1.__name__)51 current_scope = {key_op: func1_kwargs.copy()}52 with self.test_session():53 with scopes.arg_scope([func1], a=1, b=None, c=[1]) as scope1:54 pass55 with scopes.arg_scope(scope1) as scope:56 self.assertDictEqual(scope, current_scope)57 def testReuseArgScopeNested(self):58 func1_kwargs = {'a': 1, 'b': None, 'c': [1]}59 func2_kwargs = {'b': 2, 'd': [2]}60 key = lambda f: (f.__module__, f.__name__)61 current_scope1 = {key(func1): func1_kwargs.copy()}62 current_scope2 = {key(func1): func1_kwargs.copy(),63 key(func2): func2_kwargs.copy()}64 with self.test_session():65 with scopes.arg_scope([func1], a=1, b=None, c=[1]) as scope1:66 with scopes.arg_scope([func2], b=2, d=[2]) as scope2:67 pass68 with scopes.arg_scope(scope1):69 self.assertDictEqual(scopes._current_arg_scope(), current_scope1)70 with scopes.arg_scope(scope2):71 self.assertDictEqual(scopes._current_arg_scope(), current_scope2)72 def testSimpleArgScope(self):73 func1_args = (0,)74 func1_kwargs = {'a': 1, 'b': None, 'c': [1]}75 with self.test_session():76 with scopes.arg_scope([func1], a=1, b=None, c=[1]):77 args, kwargs = func1(0)78 self.assertTupleEqual(args, func1_args)79 self.assertDictEqual(kwargs, func1_kwargs)80 def testSimpleArgScopeWithTuple(self):81 func1_args = (0,)82 func1_kwargs = {'a': 1, 'b': None, 'c': [1]}83 with self.test_session():84 with scopes.arg_scope((func1,), a=1, b=None, c=[1]):85 args, kwargs = func1(0)86 self.assertTupleEqual(args, func1_args)87 self.assertDictEqual(kwargs, func1_kwargs)88 def testOverwriteArgScope(self):89 func1_args = (0,)90 func1_kwargs = {'a': 1, 'b': 2, 'c': [1]}91 with scopes.arg_scope([func1], a=1, b=None, c=[1]):92 args, kwargs = func1(0, b=2)93 self.assertTupleEqual(args, func1_args)94 self.assertDictEqual(kwargs, func1_kwargs)95 def testNestedArgScope(self):96 func1_args = (0,)97 func1_kwargs = {'a': 1, 'b': None, 'c': [1]}98 with scopes.arg_scope([func1], a=1, b=None, c=[1]):99 args, kwargs = func1(0)100 self.assertTupleEqual(args, func1_args)101 self.assertDictEqual(kwargs, func1_kwargs)102 func1_kwargs['b'] = 2103 with scopes.arg_scope([func1], b=2):104 args, kwargs = func1(0)105 self.assertTupleEqual(args, func1_args)106 self.assertDictEqual(kwargs, func1_kwargs)107 def testSharedArgScope(self):108 func1_args = (0,)109 func1_kwargs = {'a': 1, 'b': None, 'c': [1]}110 with scopes.arg_scope([func1, func2], a=1, b=None, c=[1]):111 args, kwargs = func1(0)112 self.assertTupleEqual(args, func1_args)113 self.assertDictEqual(kwargs, func1_kwargs)114 args, kwargs = func2(0)115 self.assertTupleEqual(args, func1_args)116 self.assertDictEqual(kwargs, func1_kwargs)117 def testSharedArgScopeTuple(self):118 func1_args = (0,)119 func1_kwargs = {'a': 1, 'b': None, 'c': [1]}120 with scopes.arg_scope((func1, func2), a=1, b=None, c=[1]):121 args, kwargs = func1(0)122 self.assertTupleEqual(args, func1_args)123 self.assertDictEqual(kwargs, func1_kwargs)124 args, kwargs = func2(0)125 self.assertTupleEqual(args, func1_args)126 self.assertDictEqual(kwargs, func1_kwargs)127 def testPartiallySharedArgScope(self):128 func1_args = (0,)129 func1_kwargs = {'a': 1, 'b': None, 'c': [1]}130 func2_args = (1,)131 func2_kwargs = {'a': 1, 'b': None, 'd': [2]}132 with scopes.arg_scope([func1, func2], a=1, b=None):133 with scopes.arg_scope([func1], c=[1]), scopes.arg_scope([func2], d=[2]):134 args, kwargs = func1(0)135 self.assertTupleEqual(args, func1_args)136 self.assertDictEqual(kwargs, func1_kwargs)137 args, kwargs = func2(1)138 self.assertTupleEqual(args, func2_args)139 self.assertDictEqual(kwargs, func2_kwargs)140if __name__ == '__main__':...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful