def test_ttl(self): cd = cache.CacheDict(0.1) cd['foo'] = 'bar' assert 'foo' in cd assert cd['foo'] == 'bar' time.sleep(0.1) assert 'foo' not in cd # make sure that a get would get a regular old key error self.assertRaises(KeyError, cd.__getitem__, 'foo')
def test_ttl(self): cd = cache.CacheDict(0.1) cd['foo'] = 'bar' self.assertIn('foo', cd) self.assertEqual(cd['foo'], 'bar') time.sleep(0.2) self.assertNotIn('foo', cd) # make sure that a get would get a regular old key error self.assertRaises(KeyError, cd.__getitem__, 'foo')
def test_ttl(self): cd = cache.CacheDict(0.1) cd["foo"] = "bar" self.assertIn("foo", cd) self.assertEqual(cd["foo"], "bar") time.sleep(0.2) self.assertNotIn("foo", cd) # make sure that a get would get a regular old key error self.assertRaises(KeyError, cd.__getitem__, "foo")
def test_ttl(): cd = cache.CacheDict(0.1) cd["foo"] = "bar" assert "foo" in cd assert cd["foo"] == "bar" time.sleep(0.2) assert "foo" not in cd # make sure that a get would get a regular old key error with pytest.raises(KeyError): cd["foo"] # pylint: disable=pointless-statement
def test_sanity(self): ''' Make sure you can instantiate etc. ''' cd = cache.CacheDict(5) self.assertIsInstance(cd, cache.CacheDict) # do some tests to make sure it looks like a dict self.assertNotIn('foo', cd) cd['foo'] = 'bar' self.assertEqual(cd['foo'], 'bar') del cd['foo'] self.assertNotIn('foo', cd)
def test_sanity(self): ''' Make sure you can instantiate etc. ''' cd = cache.CacheDict(5) assert isinstance(cd, cache.CacheDict) # do some tests to make sure it looks like a dict assert 'foo' not in cd cd['foo'] = 'bar' assert cd['foo'] == 'bar' del cd['foo'] assert 'foo' not in cd
def test_sanity(self): """ Make sure you can instantiate etc. """ cd = cache.CacheDict(5) self.assertIsInstance(cd, cache.CacheDict) # do some tests to make sure it looks like a dict self.assertNotIn("foo", cd) cd["foo"] = "bar" self.assertEqual(cd["foo"], "bar") del cd["foo"] self.assertNotIn("foo", cd)
def test_sanity(): """ Make sure you can instantiate etc. """ cd = cache.CacheDict(5) assert isinstance(cd, cache.CacheDict) # do some tests to make sure it looks like a dict assert "foo" not in cd cd["foo"] = "bar" assert cd["foo"] == "bar" del cd["foo"] assert "foo" not in cd