|
@@ 494-508 (lines=15) @@
|
| 491 |
|
|
| 492 |
|
class Test_50_load_and_dump(TestBaseWithIOMultiFiles): |
| 493 |
|
|
| 494 |
|
def test_30_dump_and_load(self): |
| 495 |
|
TT.dump(self.dic, self.a_path) |
| 496 |
|
TT.dump(self.upd, self.b_path) |
| 497 |
|
|
| 498 |
|
self.assertTrue(os.path.exists(self.a_path)) |
| 499 |
|
self.assertTrue(os.path.exists(self.b_path)) |
| 500 |
|
|
| 501 |
|
res = TT.load(self.a_path) |
| 502 |
|
self.assert_dicts_equal(res, self.dic) |
| 503 |
|
|
| 504 |
|
res = TT.load(self.g_path) |
| 505 |
|
self.assert_dicts_equal(res, self.exp) |
| 506 |
|
|
| 507 |
|
res = TT.load([self.a_path, self.b_path]) |
| 508 |
|
self.assert_dicts_equal(res, self.exp) |
| 509 |
|
|
| 510 |
|
def test_31_dump_and_load__to_from_stream(self): |
| 511 |
|
with TT.open(self.a_path, mode='w') as strm: |
|
@@ 373-387 (lines=15) @@
|
| 370 |
|
|
| 371 |
|
class Test_40_multi_load_with_strategies(TestBaseWithIOMultiFiles): |
| 372 |
|
|
| 373 |
|
def _check_multi_load_with_strategy(self, exp, merge=TT.MS_DICTS): |
| 374 |
|
TT.dump(self.dic, self.a_path) |
| 375 |
|
TT.dump(self.upd, self.b_path) |
| 376 |
|
|
| 377 |
|
self.assertTrue(os.path.exists(self.a_path)) |
| 378 |
|
self.assertTrue(os.path.exists(self.b_path)) |
| 379 |
|
|
| 380 |
|
res0 = TT.multi_load(self.g_path, ac_merge=merge) |
| 381 |
|
res1 = TT.multi_load([self.g_path, self.b_path], ac_merge=merge) |
| 382 |
|
|
| 383 |
|
self.assertTrue(res0) |
| 384 |
|
self.assertTrue(res1) |
| 385 |
|
|
| 386 |
|
self.assert_dicts_equal(res0, exp) |
| 387 |
|
self.assert_dicts_equal(res1, exp) |
| 388 |
|
|
| 389 |
|
def test_10_default_merge_strategy(self): |
| 390 |
|
exp = copy.deepcopy(self.upd) |