summaryrefslogtreecommitdiff
path: root/tests/test_zone.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_zone.py')
-rw-r--r--tests/test_zone.py29
1 files changed, 27 insertions, 2 deletions
diff --git a/tests/test_zone.py b/tests/test_zone.py
index 36428b1..9857f80 100644
--- a/tests/test_zone.py
+++ b/tests/test_zone.py
@@ -35,8 +35,7 @@ import dns.rrset
import dns.zone
import dns.node
-def here(filename):
- return os.path.join(os.path.dirname(__file__), filename)
+from tests.util import here
example_text = """$TTL 3600
$ORIGIN example.
@@ -175,6 +174,23 @@ $ORIGIN example.
@ 300 ns ns2
"""
+example_comments_text = """$TTL 3600
+$ORIGIN example.
+@ soa foo bar (1 ; not kept
+2 3 4 5) ; kept
+@ ns ns1
+@ ns ns2
+ns1 a 10.0.0.1 ; comment1
+ns2 a 10.0.0.2 ; comment2
+"""
+
+example_comments_text_output = """@ 3600 IN SOA foo bar 1 2 3 4 5 ; kept
+@ 3600 IN NS ns1
+@ 3600 IN NS ns2
+ns1 3600 IN A 10.0.0.1 ; comment1
+ns2 3600 IN A 10.0.0.2 ; comment2
+"""
+
_keep_output = True
def _rdata_sort(a):
@@ -746,5 +762,14 @@ class ZoneTestCase(unittest.TestCase):
self.assertEqual(z._validate_name('foo.bar.example.'),
dns.name.from_text('foo.bar', None))
+ def testComments(self):
+ z = dns.zone.from_text(example_comments_text, 'example.',
+ relativize=True)
+ f = StringIO()
+ z.to_file(f, want_comments=True)
+ out = f.getvalue()
+ f.close()
+ self.assertEqual(out, example_comments_text_output)
+
if __name__ == '__main__':
unittest.main()