Пример #1
0
 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')
Пример #2
0
    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')
Пример #3
0
    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")
Пример #4
0
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
Пример #5
0
    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)
Пример #6
0
    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
Пример #7
0
    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)
Пример #8
0
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