Skip to content

Commit

Permalink
nail the fact that AttributeError raised in a @Property decorated met…
Browse files Browse the repository at this point in the history
…hod gets masked by traversal
  • Loading branch information
agroszer committed Feb 25, 2013
1 parent 23f37d9 commit 0bce274
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/zope/traversing/tests/test_traverser.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,16 @@ def testTraversingDoesntFailOnStrings(self):
self.assertRaises(LocationError, tr.traverse, 'foo/baz')


class ExceptionRaiser(C):
@property
def valueerror(self):
raise ValueError('booom')

@property
def attributeerror(self):
raise AttributeError('booom')


class RestrictedTraverseTests(PlacelessSetup, unittest.TestCase):
_oldPolicy = None
_deniedNames = ()
Expand Down Expand Up @@ -211,6 +221,24 @@ def testItemDenied(self):
folder)
self.assertEquals(tr.traverse(('folder',)), folder)

def testException(self):
# nail the fact that AttributeError raised in a @property
# decorated method gets masked by traversal
self.root.foobar = ExceptionRaiser('foobar')

endInteraction()
newInteraction(ParticipationStub('no one'))
tr = Traverser(self.root)

# AttributeError becomes LocationError if there's no __getitem__
# on the object
self.assertRaises(LocationError, tr.traverse,
('foobar', 'attributeerror'))
# Other exceptions raised as usual
self.assertRaises(ValueError, tr.traverse,
('foobar', 'valueerror'))


class DefaultTraversableTests(unittest.TestCase):
def testImplementsITraversable(self):
self.failUnless(ITraversable.providedBy(DefaultTraversable(None)))
Expand Down

0 comments on commit 0bce274

Please sign in to comment.