diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-06-02 16:36:37 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-06-02 16:36:37 +0000 |
| commit | e6592741ebf5ce940ecf5cbbbab7c42211df6a26 (patch) | |
| tree | a47bfb3a970fa9989e7de65918785f03147566b3 /repoze | |
| parent | fcd16e26db10fb99f88a8e7afa36653350488b39 (diff) | |
| download | pyramid-e6592741ebf5ce940ecf5cbbbab7c42211df6a26.tar.gz pyramid-e6592741ebf5ce940ecf5cbbbab7c42211df6a26.tar.bz2 pyramid-e6592741ebf5ce940ecf5cbbbab7c42211df6a26.zip | |
- The ``repoze.bfg.location.locate`` API was removed: it didn't do
enough to be very helpful and had a misleading name.
Diffstat (limited to 'repoze')
| -rw-r--r-- | repoze/bfg/location.py | 10 | ||||
| -rw-r--r-- | repoze/bfg/tests/test_location.py | 40 |
2 files changed, 17 insertions, 33 deletions
diff --git a/repoze/bfg/location.py b/repoze/bfg/location.py index 7e9d622c2..adb01d129 100644 --- a/repoze/bfg/location.py +++ b/repoze/bfg/location.py @@ -32,16 +32,6 @@ def inside(model1, model2): return False -def locate(model, parent, name=None): - """ - Directly set ``model`` 's ``__parent__`` attribute to the - ``parent`` object (also a model), and its ``__name__`` to the - supplied ``name`` argument, and return the model. - """ - model.__parent__ = parent - model.__name__ = name - return model - def lineage(model): """ Return a generator representing the model lineage. The generator diff --git a/repoze/bfg/tests/test_location.py b/repoze/bfg/tests/test_location.py index 9de059a86..9b8360f8b 100644 --- a/repoze/bfg/tests/test_location.py +++ b/repoze/bfg/tests/test_location.py @@ -1,42 +1,36 @@ import unittest -class TestLocation(unittest.TestCase): +class TestInside(unittest.TestCase): + def _callFUT(self, one, two): + from repoze.bfg.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 - from repoze.bfg.location import inside - self.assertEqual(inside(o1, o1), True) - self.assertEqual(inside(o2, o1), True) - self.assertEqual(inside(o3, o1), True) - self.assertEqual(inside(o4, o1), True) - self.assertEqual(inside(o1, o4), False) - self.assertEqual(inside(o1, None), False) - - def test_locate(self): - from repoze.bfg.location import locate - a = Location() - parent = Location() - a_located = locate(a, parent, 'a') - self.failUnless(a_located is a) - self.failUnless(a_located.__parent__ is parent) - self.assertEqual(a_located.__name__, 'a') - # If we locate the object again, nothing special happens: + 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) - a_located_2 = locate(a_located, parent, 'a') - self.failUnless(a_located_2 is a_located) +class TestLineage(unittest.TestCase): + def _callFUT(self, context): + from repoze.bfg.location import lineage + return lineage(context) def test_lineage(self): - from repoze.bfg.location import lineage o1 = Location() o2 = Location(); o2.__parent__ = o1 o3 = Location(); o3.__parent__ = o2 o4 = Location(); o4.__parent__ = o3 - result = list(lineage(o3)) + result = list(self._callFUT(o3)) self.assertEqual(result, [o3, o2, o1]) - result = list(lineage(o1)) + result = list(self._callFUT(o1)) self.assertEqual(result, [o1]) from repoze.bfg.interfaces import ILocation |
