Merge pull request #408 from rachmadaniHaryono/feature/yaml-load

fix: dev: use modified safe loader
This commit is contained in:
Mischievous Meerkat 2019-07-23 18:54:24 +05:30 committed by GitHub
commit 771b292614
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,6 +64,16 @@ def setup():
os.remove(TEST_TEMP_DBFILE_PATH) 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): class TestBukuDb(unittest.TestCase):
def setUp(self): def setUp(self):
@ -1321,7 +1331,7 @@ def test_load_chrome_database(chrome_db, add_pt):
try: try:
res_yaml = yaml.load(f, Loader=yaml.FullLoader) res_yaml = yaml.load(f, Loader=yaml.FullLoader)
except RuntimeError: except RuntimeError:
res_yaml = yaml.safe_load(f) res_yaml = yaml.load(f, Loader=PrettySafeLoader)
# init # init
import buku import buku
bdb = buku.BukuDb() bdb = buku.BukuDb()
@ -1365,7 +1375,7 @@ def test_load_firefox_database(firefox_db, add_pt):
try: try:
res_yaml = yaml.load(f) res_yaml = yaml.load(f)
except RuntimeError: except RuntimeError:
res_yaml = yaml.safe_load(f) res_yaml = yaml.load(f, Loader=PrettySafeLoader)
# init # init
import buku import buku
bdb = buku.BukuDb() bdb = buku.BukuDb()