summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2005-10-06 06:25:52 +0000
committerBob Halley <halley@dnspython.org>2005-10-06 06:25:52 +0000
commit7abb1f23f3c44901c0bcc4aa183c30548e6a1786 (patch)
tree6e877bc759ab7663ffd0611cf1eec40a48917891 /tests
parent2cf8da1e004f17dca34c6f4eee12a59ab55b37d9 (diff)
downloaddnspython-7abb1f23f3c44901c0bcc4aa183c30548e6a1786.tar.gz
add dns.name.Name.parent()
Diffstat (limited to 'tests')
-rw-r--r--tests/name.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/name.py b/tests/name.py
index 24abfcd..cc7ced5 100644
--- a/tests/name.py
+++ b/tests/name.py
@@ -589,5 +589,27 @@ class NameTestCase(unittest.TestCase):
(n, cused) = dns.name.from_wire(w, 0)
self.failUnlessRaises(dns.name.BadLabelType, bad)
+ def testParent1(self):
+ n = dns.name.from_text('foo.bar.')
+ self.failUnless(n.parent() == dns.name.from_text('bar.'))
+ self.failUnless(n.parent().parent() == dns.name.root)
+
+ def testParent2(self):
+ n = dns.name.from_text('foo.bar', None)
+ self.failUnless(n.parent() == dns.name.from_text('bar', None))
+ self.failUnless(n.parent().parent() == dns.name.empty)
+
+ def testParent3(self):
+ def bad():
+ n = dns.name.root
+ n.parent()
+ self.failUnlessRaises(dns.name.NoParent, bad)
+
+ def testParent4(self):
+ def bad():
+ n = dns.name.empty
+ n.parent()
+ self.failUnlessRaises(dns.name.NoParent, bad)
+
if __name__ == '__main__':
unittest.main()