X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=bindings%2Fpython-cffi%2Ftests%2Ftest_config.py;h=2a7f42f0e17d0868382a9b0d5276ca2ce6912e87;hb=9ddd13f75827f4972872c8766320c7cb80b1819b;hp=1b2695f51707a9d447c0b3160a1f269d025f0f17;hpb=1bca41698a03980b701558fb5c481ef0a340460d;p=notmuch diff --git a/bindings/python-cffi/tests/test_config.py b/bindings/python-cffi/tests/test_config.py index 1b2695f5..2a7f42f0 100644 --- a/bindings/python-cffi/tests/test_config.py +++ b/bindings/python-cffi/tests/test_config.py @@ -23,9 +23,9 @@ class TestIter: def test_set_get(self, maildir): # Ensure get-set works from different db objects - with dbmod.Database.create(maildir.path) as db0: + with dbmod.Database.create(maildir.path, config=dbmod.Database.CONFIG.EMPTY) as db0: db0.config['spam'] = 'ham' - with dbmod.Database(maildir.path) as db1: + with dbmod.Database(maildir.path, config=dbmod.Database.CONFIG.EMPTY) as db1: assert db1.config['spam'] == 'ham' def test_get_keyerror(self, db): @@ -34,20 +34,24 @@ class TestIter: print(repr(val)) def test_iter(self, db): - assert list(db.config) == [] - db.config['spam'] = 'ham' - db.config['eggs'] = 'bacon' - assert set(db.config) == {'spam', 'eggs'} - assert set(db.config.keys()) == {'spam', 'eggs'} - assert set(db.config.values()) == {'ham', 'bacon'} - assert set(db.config.items()) == {('spam', 'ham'), ('eggs', 'bacon')} + def has_prefix(x): + return x.startswith('TEST.') + + assert [ x for x in db.config if has_prefix(x) ] == [] + db.config['TEST.spam'] = 'TEST.ham' + db.config['TEST.eggs'] = 'TEST.bacon' + assert { x for x in db.config if has_prefix(x) } == {'TEST.spam', 'TEST.eggs'} + assert { x for x in db.config.keys() if has_prefix(x) } == {'TEST.spam', 'TEST.eggs'} + assert { x for x in db.config.values() if has_prefix(x) } == {'TEST.ham', 'TEST.bacon'} + assert { (x, y) for (x,y) in db.config.items() if has_prefix(x) } == \ + {('TEST.spam', 'TEST.ham'), ('TEST.eggs', 'TEST.bacon')} def test_len(self, db): - assert len(db.config) == 0 + defaults = len(db.config) db.config['spam'] = 'ham' - assert len(db.config) == 1 + assert len(db.config) == defaults + 1 db.config['eggs'] = 'bacon' - assert len(db.config) == 2 + assert len(db.config) == defaults + 2 def test_del(self, db): db.config['spam'] = 'ham'