Пример #1
0
class TestCaching(object):
    def setup_method(self, method):
        self.object = Bunch()
        self.cache = Caching(self.object, 'cache')

    def test_get_not_present(self):
        with pytest.raises(NotInCache):
            self.cache.get()

    def test_get_present(self):
        self.object.cache = 'foo'

        assert self.cache.get() == 'foo'

    def test_delete_not_present(self):
        with pytest.raises(NotInCache):
            self.cache.delete()

    def test_delete_present(self):
        self.object.cache = 'foo'

        assert self.cache.delete() == 'foo'
        assert not hasattr(self.object, 'cache')

    def test_set(self):
        assert self.cache.set('foo') == 'foo'
        assert self.object.cache == 'foo'
Пример #2
0
 def setup_method(self, method):
     self.object = Bunch()
     self.cache = Caching(self.object, 'cache')