Kaydet (Commit) 345a0967 authored tarafından Adrian Holovaty's avatar Adrian Holovaty

Negligible formatting changes to tests/regressiontests/templates/loaders.py

git-svn-id: http://code.djangoproject.com/svn/django/trunk@7750 bcc190cf-cafb-0310-a4f2-bffc1f526a37
üst fbef599f
# -*- coding: utf-8 -*-
""" """
Test cases for the template loaders Test cases for the template loaders
Note: This test requires setuptools!
""" """
from django.conf import settings from django.conf import settings
...@@ -17,7 +18,7 @@ import StringIO ...@@ -17,7 +18,7 @@ import StringIO
from django.template import TemplateDoesNotExist from django.template import TemplateDoesNotExist
from django.template.loaders.eggs import load_template_source as lts_egg from django.template.loaders.eggs import load_template_source as lts_egg
#Mock classes and objects for pkg_resources functions # Mock classes and objects for pkg_resources functions.
class MockProvider(pkg_resources.NullProvider): class MockProvider(pkg_resources.NullProvider):
def __init__(self, module): def __init__(self, module):
pkg_resources.NullProvider.__init__(self, module) pkg_resources.NullProvider.__init__(self, module)
...@@ -35,13 +36,14 @@ class MockProvider(pkg_resources.NullProvider): ...@@ -35,13 +36,14 @@ class MockProvider(pkg_resources.NullProvider):
def _get(self, path): def _get(self, path):
return self.module._resources[path].read() return self.module._resources[path].read()
class MockLoader(object): pass class MockLoader(object):
pass
def create_egg(name, resources): def create_egg(name, resources):
""" """
Creates a mock egg with a list of resources Creates a mock egg with a list of resources.
name: The name of the module name: The name of the module.
resources: A dictionary of resources. Keys are the names and values the the data. resources: A dictionary of resources. Keys are the names and values the the data.
""" """
egg = imp.new_module(name) egg = imp.new_module(name)
...@@ -49,7 +51,6 @@ def create_egg(name, resources): ...@@ -49,7 +51,6 @@ def create_egg(name, resources):
egg._resources = resources egg._resources = resources
sys.modules[name] = egg sys.modules[name] = egg
class EggLoader(unittest.TestCase): class EggLoader(unittest.TestCase):
def setUp(self): def setUp(self):
pkg_resources._provider_factories[MockLoader] = MockProvider pkg_resources._provider_factories[MockLoader] = MockProvider
...@@ -87,6 +88,5 @@ class EggLoader(unittest.TestCase): ...@@ -87,6 +88,5 @@ class EggLoader(unittest.TestCase):
settings.INSTALLED_APPS = [] settings.INSTALLED_APPS = []
self.assertRaises(TemplateDoesNotExist, lts_egg, "y.html") self.assertRaises(TemplateDoesNotExist, lts_egg, "y.html")
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment