From e01caa19f164ab6b9f14d02b6f095a1b8976dac7 Mon Sep 17 00:00:00 2001 From: rachmadaniHaryono Date: Mon, 22 Jul 2019 07:21:49 +0800 Subject: [PATCH] fix: dev: use modified safe loader --- tests/test_bukuDb.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/test_bukuDb.py b/tests/test_bukuDb.py index 5d18aef..9de2029 100644 --- a/tests/test_bukuDb.py +++ b/tests/test_bukuDb.py @@ -64,6 +64,16 @@ def setup(): os.remove(TEST_TEMP_DBFILE_PATH) +class PrettySafeLoader(yaml.SafeLoader): + def construct_python_tuple(self, node): + return tuple(self.construct_sequence(node)) + + +PrettySafeLoader.add_constructor( + u'tag:yaml.org,2002:python/tuple', + PrettySafeLoader.construct_python_tuple) + + class TestBukuDb(unittest.TestCase): def setUp(self): @@ -1321,7 +1331,7 @@ def test_load_chrome_database(chrome_db, add_pt): try: res_yaml = yaml.load(f, Loader=yaml.FullLoader) except RuntimeError: - res_yaml = yaml.safe_load(f) + res_yaml = yaml.load(f, Loader=PrettySafeLoader) # init import buku bdb = buku.BukuDb() @@ -1365,7 +1375,7 @@ def test_load_firefox_database(firefox_db, add_pt): try: res_yaml = yaml.load(f) except RuntimeError: - res_yaml = yaml.safe_load(f) + res_yaml = yaml.load(f, Loader=PrettySafeLoader) # init import buku bdb = buku.BukuDb()