diff options
| author | Michael Merickel <github@m.merickel.org> | 2018-10-15 09:03:53 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-10-15 09:03:53 -0500 |
| commit | 81576ee51564c49d5ff3c1c07f214f22a8438231 (patch) | |
| tree | 5b3fe0b39a0fc33d545733d821738845909f638c /tests/test_location.py | |
| parent | 433efe06191a7007ca8c5bf8fafee5c7c1439ebb (diff) | |
| parent | 17e3abf320f6d9cd90f7e5a0352280c2fef584af (diff) | |
| download | pyramid-81576ee51564c49d5ff3c1c07f214f22a8438231.tar.gz pyramid-81576ee51564c49d5ff3c1c07f214f22a8438231.tar.bz2 pyramid-81576ee51564c49d5ff3c1c07f214f22a8438231.zip | |
Merge pull request #3387 from mmerickel/src-folder-refactor
refactor pyramid tests into a tests folder and package into a src folder
Diffstat (limited to 'tests/test_location.py')
| -rw-r--r-- | tests/test_location.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/test_location.py b/tests/test_location.py new file mode 100644 index 000000000..e1f47f4ab --- /dev/null +++ b/tests/test_location.py @@ -0,0 +1,40 @@ +import unittest + +class TestInside(unittest.TestCase): + def _callFUT(self, one, two): + from pyramid.location import inside + return inside(one, two) + + def test_inside(self): + o1 = Location() + o2 = Location(); o2.__parent__ = o1 + o3 = Location(); o3.__parent__ = o2 + o4 = Location(); o4.__parent__ = o3 + + self.assertEqual(self._callFUT(o1, o1), True) + self.assertEqual(self._callFUT(o2, o1), True) + self.assertEqual(self._callFUT(o3, o1), True) + self.assertEqual(self._callFUT(o4, o1), True) + self.assertEqual(self._callFUT(o1, o4), False) + self.assertEqual(self._callFUT(o1, None), False) + +class TestLineage(unittest.TestCase): + def _callFUT(self, context): + from pyramid.location import lineage + return lineage(context) + + def test_lineage(self): + o1 = Location() + o2 = Location(); o2.__parent__ = o1 + o3 = Location(); o3.__parent__ = o2 + o4 = Location(); o4.__parent__ = o3 + result = list(self._callFUT(o3)) + self.assertEqual(result, [o3, o2, o1]) + result = list(self._callFUT(o1)) + self.assertEqual(result, [o1]) + +from pyramid.interfaces import ILocation +from zope.interface import implementer +@implementer(ILocation) +class Location(object): + __name__ = __parent__ = None |
