aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/Jinja2/py2/tests/test_bytecode_cache.py
diff options
context:
space:
mode:
authorfloatdrop <floatdrop@yandex-team.ru>2022-02-10 16:47:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:15 +0300
commite63b84f1d39557d9e46ac380b1f388271894293c (patch)
tree338cdaff3fb027e030b847db66df06019a0e3149 /contrib/python/Jinja2/py2/tests/test_bytecode_cache.py
parentf60febb7ea449535e7b073c386c7ff0539637fc0 (diff)
downloadydb-e63b84f1d39557d9e46ac380b1f388271894293c.tar.gz
Restoring authorship annotation for <floatdrop@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/python/Jinja2/py2/tests/test_bytecode_cache.py')
-rw-r--r--contrib/python/Jinja2/py2/tests/test_bytecode_cache.py124
1 files changed, 62 insertions, 62 deletions
diff --git a/contrib/python/Jinja2/py2/tests/test_bytecode_cache.py b/contrib/python/Jinja2/py2/tests/test_bytecode_cache.py
index c7882b1a2d..9a98dc4baa 100644
--- a/contrib/python/Jinja2/py2/tests/test_bytecode_cache.py
+++ b/contrib/python/Jinja2/py2/tests/test_bytecode_cache.py
@@ -1,78 +1,78 @@
-# -*- coding: utf-8 -*-
-import pytest
-
-from jinja2 import Environment
+# -*- coding: utf-8 -*-
+import pytest
+
+from jinja2 import Environment
from jinja2.bccache import Bucket
from jinja2.bccache import FileSystemBytecodeCache
from jinja2.bccache import MemcachedBytecodeCache
-from jinja2.exceptions import TemplateNotFound
-
-
-@pytest.fixture
+from jinja2.exceptions import TemplateNotFound
+
+
+@pytest.fixture
def env(package_loader, tmp_path):
bytecode_cache = FileSystemBytecodeCache(str(tmp_path))
return Environment(loader=package_loader, bytecode_cache=bytecode_cache)
-
-
-class TestByteCodeCache(object):
- def test_simple(self, env):
+
+
+class TestByteCodeCache(object):
+ def test_simple(self, env):
tmpl = env.get_template("test.html")
assert tmpl.render().strip() == "BAR"
pytest.raises(TemplateNotFound, env.get_template, "missing.html")
-
-
-class MockMemcached(object):
- class Error(Exception):
- pass
-
- key = None
- value = None
- timeout = None
-
- def get(self, key):
- return self.value
-
- def set(self, key, value, timeout=None):
- self.key = key
- self.value = value
- self.timeout = timeout
-
- def get_side_effect(self, key):
- raise self.Error()
-
- def set_side_effect(self, *args):
- raise self.Error()
-
-
-class TestMemcachedBytecodeCache(object):
- def test_dump_load(self):
- memcached = MockMemcached()
- m = MemcachedBytecodeCache(memcached)
-
+
+
+class MockMemcached(object):
+ class Error(Exception):
+ pass
+
+ key = None
+ value = None
+ timeout = None
+
+ def get(self, key):
+ return self.value
+
+ def set(self, key, value, timeout=None):
+ self.key = key
+ self.value = value
+ self.timeout = timeout
+
+ def get_side_effect(self, key):
+ raise self.Error()
+
+ def set_side_effect(self, *args):
+ raise self.Error()
+
+
+class TestMemcachedBytecodeCache(object):
+ def test_dump_load(self):
+ memcached = MockMemcached()
+ m = MemcachedBytecodeCache(memcached)
+
b = Bucket(None, "key", "")
b.code = "code"
- m.dump_bytecode(b)
+ m.dump_bytecode(b)
assert memcached.key == "jinja2/bytecode/key"
-
+
b = Bucket(None, "key", "")
- m.load_bytecode(b)
+ m.load_bytecode(b)
assert b.code == "code"
-
- def test_exception(self):
- memcached = MockMemcached()
- memcached.get = memcached.get_side_effect
- memcached.set = memcached.set_side_effect
- m = MemcachedBytecodeCache(memcached)
+
+ def test_exception(self):
+ memcached = MockMemcached()
+ memcached.get = memcached.get_side_effect
+ memcached.set = memcached.set_side_effect
+ m = MemcachedBytecodeCache(memcached)
b = Bucket(None, "key", "")
b.code = "code"
-
- m.dump_bytecode(b)
- m.load_bytecode(b)
-
- m.ignore_memcache_errors = False
-
- with pytest.raises(MockMemcached.Error):
- m.dump_bytecode(b)
-
- with pytest.raises(MockMemcached.Error):
- m.load_bytecode(b)
+
+ m.dump_bytecode(b)
+ m.load_bytecode(b)
+
+ m.ignore_memcache_errors = False
+
+ with pytest.raises(MockMemcached.Error):
+ m.dump_bytecode(b)
+
+ with pytest.raises(MockMemcached.Error):
+ m.load_bytecode(b)