More coverage for Path and AttrPath
This commit is contained in:
@@ -74,7 +74,7 @@ class AttrPath(object):
|
||||
"Invert failed because property '%s' of class "
|
||||
"%s has no backref." % (
|
||||
prop.key,
|
||||
prop.mapper.class_.__name__
|
||||
prop.parent.class_.__name__
|
||||
)
|
||||
)
|
||||
return backref
|
||||
@@ -90,7 +90,7 @@ class AttrPath(object):
|
||||
if result[0] is self.parts[0]:
|
||||
class_ = self.class_
|
||||
else:
|
||||
class_ = result[0].mapper.class_
|
||||
class_ = result[0].parent.class_
|
||||
return self.__class__(
|
||||
class_,
|
||||
self.path[slice]
|
||||
|
@@ -46,6 +46,7 @@ class TestAttrPath(TestCase):
|
||||
self.Document.sections,
|
||||
self.Section.subsections
|
||||
]
|
||||
assert str(path.path) == 'sections.subsections'
|
||||
|
||||
def test_len(self):
|
||||
len(AttrPath(self.SubSection, 'section.document')) == 2
|
||||
@@ -77,6 +78,8 @@ class TestAttrPath(TestCase):
|
||||
def test_getitem_with_slice(self):
|
||||
path = AttrPath(self.SubSection, 'section.document')
|
||||
assert path[:] == AttrPath(self.SubSection, 'section.document')
|
||||
assert path[:-1] == AttrPath(self.SubSection, 'section')
|
||||
assert path[1:] == AttrPath(self.Section, 'document')
|
||||
|
||||
def test_eq(self):
|
||||
assert (
|
||||
|
Reference in New Issue
Block a user