def test_open_readwrite_create(
     self,
     name: str,
     mapping: CacheDictMapping,
     extra: Extra,
 ):
     c = CacheDict.open_readwrite(
         path=f"{self.tmp_dir}/{name}.create.sqlite",
         mapping=mapping,
         create=ToCreate.DATABASE,
         sqlite_params=extra.sqlite_params,
     )
     self.assertNotEqual(c, None)
    def test_open_readwrite(self, name: str, mapping: CacheDictMapping, extra: Extra):
        c = CacheDict.open_readwrite(
            path=f"{self.tmp_dir}/{name}.readwrite.sqlite",
            mapping=mapping,
            sqlite_params=extra.sqlite_params,
        )
        if extra.preexisting:
            preexist = extra.preexisting
        else:
            preexist = {}
        for (key, expected) in preexist.items():
            with self.subTest(key=key, expected=expected):
                if expected is not NOT_PRESENT:
                    actual = c[key]
                    self.assertEqual(actual, expected)
                else:
                    with self.assertRaises(KeyError) as raised_context:
                        _ = c[key]
                    _ = raised_context.exception

        self.assertNotEqual(c, None)