More coverage for Path and AttrPath

This commit is contained in:
Konsta Vesterinen
2014-02-18 15:20:12 +02:00
parent 6b64bf24ed
commit 7fe7a8b554
2 changed files with 5 additions and 2 deletions

View File

@@ -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]

View File

@@ -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 (