Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also fixes #3 Install zope.pagetemplate for tests and ensure that we use the correct namespaces.
- Loading branch information
Showing
5 changed files
with
53 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Tests for namespaces.py. | ||
""" | ||
|
||
import unittest | ||
|
||
from z3c.pt import namespaces | ||
|
||
class TestAdapterNamespaces(unittest.TestCase): | ||
|
||
def test_registered_name(self): | ||
nss = namespaces.AdapterNamespaces() | ||
func = lambda ctx: ctx | ||
nss.registerFunctionNamespace('ns', func) | ||
self.assertIs(func, nss['ns']) | ||
self.assertIs(func, nss.getFunctionNamespace('ns')) | ||
|
||
def test_unregistered_name(self): | ||
nss = namespaces.AdapterNamespaces() | ||
with self.assertRaises(KeyError): | ||
nss.getFunctionNamespace('ns') | ||
|
||
# but __getitem__ makes one up | ||
self.assertIsNotNone(nss['ns']) | ||
|
||
def test_using_pagetemplate_version(self): | ||
from zope.pagetemplate import engine | ||
|
||
self.assertFalse(isinstance(namespaces.function_namespaces, | ||
namespaces.AdapterNamespaces)) | ||
self.assertIsInstance(namespaces.function_namespaces, | ||
engine.AdapterNamespaces) |