diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-01-25 05:11:21 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-01-25 05:11:21 +0000 |
| commit | c8cab3395432983c2165dce196ad5204e420a900 (patch) | |
| tree | 3ef0a4b85c612513ac79779db28763f39e11907c /repoze/bfg/tests/test_security.py | |
| parent | e5cf7dbec2ccda7d2e4d79815ac441acf2ab1061 (diff) | |
| download | pyramid-c8cab3395432983c2165dce196ad5204e420a900.tar.gz pyramid-c8cab3395432983c2165dce196ad5204e420a900.tar.bz2 pyramid-c8cab3395432983c2165dce196ad5204e420a900.zip | |
Optimize flatten a bit.
Diffstat (limited to 'repoze/bfg/tests/test_security.py')
| -rw-r--r-- | repoze/bfg/tests/test_security.py | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/repoze/bfg/tests/test_security.py b/repoze/bfg/tests/test_security.py index e9f35f57f..4209f8d3d 100644 --- a/repoze/bfg/tests/test_security.py +++ b/repoze/bfg/tests/test_security.py @@ -603,7 +603,36 @@ class TestACLDenied(unittest.TestCase): self.assertEqual(str(denied), msg) self.failUnless('<ACLDenied instance at ' in repr(denied)) self.failUnless("with msg %r>" % msg in repr(denied)) - + +class TestFlatten(unittest.TestCase): + def _callFUT(self, item): + from repoze.bfg.security import flatten + return flatten(item) + + def test_str(self): + result = self._callFUT('a') + self.assertEqual(result, ['a']) + + def test_unicode(self): + result = self._callFUT(u'a') + self.assertEqual(result, [u'a']) + + def test_flat_sequence(self): + result = self._callFUT([1, 2, 3]) + self.assertEqual(result, [1, 2, 3]) + + def test_singly_nested_sequence(self): + result = self._callFUT([1, [2, 3]]) + self.assertEqual(result, [1, 2, 3]) + + def test_doubly_nested_sequence(self): + result = self._callFUT([1, [2, [3]]]) + self.assertEqual(result, [1, 2, 3]) + + def test_mix_str_unicode_sequence(self): + result = self._callFUT([1, [2, [3]], u'a', ('b', set(['c', 'd']))]) + self.assertEqual(result, [1, 2, 3, u'a', 'b', 'c', 'd']) + class DummyContext: pass |
