]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Overhaul test suite to allow testing in place.
authorBob Halley <halley@dnspython.org>
Mon, 1 Sep 2014 00:40:54 +0000 (17:40 -0700)
committerBob Halley <halley@dnspython.org>
Mon, 1 Sep 2014 00:40:54 +0000 (17:40 -0700)
19 files changed:
Makefile
dns/dnssec.py
tests/Makefile
tests/test_bugs.py [moved from tests/bugs.py with 100% similarity]
tests/test_dnssec.py [moved from tests/dnssec.py with 93% similarity]
tests/test_flags.py [moved from tests/flags.py with 100% similarity]
tests/test_generate.py [moved from tests/generate.py with 100% similarity]
tests/test_message.py [moved from tests/message.py with 100% similarity]
tests/test_name.py [moved from tests/name.py with 100% similarity]
tests/test_namedict.py [moved from tests/namedict.py with 100% similarity]
tests/test_ntoaaton.py [moved from tests/ntoaaton.py with 100% similarity]
tests/test_rdtypeandclass.py [moved from tests/rdtypeandclass.py with 100% similarity]
tests/test_resolver.py [moved from tests/resolver.py with 100% similarity]
tests/test_rrset.py [moved from tests/rrset.py with 100% similarity]
tests/test_set.py [moved from tests/set.py with 100% similarity]
tests/test_tokenizer.py [moved from tests/tokenizer.py with 100% similarity]
tests/test_update.py [moved from tests/update.py with 100% similarity]
tests/test_zone.py [moved from tests/zone.py with 100% similarity]
tests/utest.py [new file with mode: 0644]

index 74469a3257def0345f97c2ed073cd3b81b763f7d..882f6e65e324570c8e4590d0b914ed8824fed66b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -54,3 +54,8 @@ kits:
 
 tags:
        find . -name '*.py' -print | etags -
+
+check: test
+
+test:
+       cd tests; make test
index c1cd1cb7831529a6aa4da5847aa594aed962b2e2..2dd4a677f8d369282975310a749e0e9d52b1156a 100644 (file)
@@ -370,6 +370,8 @@ try:
     import Crypto.Util.number
     validate = _validate
     validate_rrsig = _validate_rrsig
+    _have_pycrypto = True
 except ImportError:
     validate = _need_pycrypto
     validate_rrsig = _need_pycrypto
+    _have_pycrypto = False
index cd6e4fa1ff666be90ef0ab5f3f2289eab09d250a..8c465dff3e8df414028c09a5d2a0a1b50d520c5a 100644 (file)
@@ -20,7 +20,4 @@ PYTHON=python3
 check: test
 
 test:
-       @for i in *.py; do \
-               echo "Running $$i:"; \
-               ${PYTHON} $$i || exit 1; \
-       done
+       ${PYTHON} ./utest.py
similarity index 100%
rename from tests/bugs.py
rename to tests/test_bugs.py
similarity index 93%
rename from tests/dnssec.py
rename to tests/test_dnssec.py
index f5fd54a29d03b2cf735cc4bcaaf30c65bab08e98..98c47888dea434817779e74bcd516febf0baa738 100644 (file)
@@ -99,22 +99,32 @@ example_ds_sha256 = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.DS,
 
 class DNSSECValidatorTestCase(unittest.TestCase):
 
+    @unittest.skipIf(not dns.dnssec._have_pycrypto,
+                     "PyCrypto cannot be imported")
     def testAbsoluteRSAGood(self):
         dns.dnssec.validate(abs_soa, abs_soa_rrsig, abs_keys, None, when)
 
+    @unittest.skipIf(not dns.dnssec._have_pycrypto,
+                     "PyCrypto cannot be imported")
     def testDuplicateKeytag(self):
         dns.dnssec.validate(abs_soa, abs_soa_rrsig, abs_keys_duplicate_keytag, None, when)
 
+    @unittest.skipIf(not dns.dnssec._have_pycrypto,
+                     "PyCrypto cannot be imported")
     def testAbsoluteRSABad(self):
         def bad():
             dns.dnssec.validate(abs_other_soa, abs_soa_rrsig, abs_keys, None,
                                 when)
         self.assertRaises(dns.dnssec.ValidationFailure, bad)
 
+    @unittest.skipIf(not dns.dnssec._have_pycrypto,
+                     "PyCrypto cannot be imported")
     def testRelativeRSAGood(self):
         dns.dnssec.validate(rel_soa, rel_soa_rrsig, rel_keys,
                             abs_dnspython_org, when)
 
+    @unittest.skipIf(not dns.dnssec._have_pycrypto,
+                     "PyCrypto cannot be imported")
     def testRelativeRSABad(self):
         def bad():
             dns.dnssec.validate(rel_other_soa, rel_soa_rrsig, rel_keys,
@@ -125,10 +135,14 @@ class DNSSECValidatorTestCase(unittest.TestCase):
         ds = dns.dnssec.make_ds(abs_dnspython_org, sep_key, 'SHA256')
         self.assertTrue(ds == good_ds)
 
+    @unittest.skipIf(not dns.dnssec._have_pycrypto,
+                     "PyCrypto cannot be imported")
     def testAbsoluteDSAGood(self):
         dns.dnssec.validate(abs_dsa_soa, abs_dsa_soa_rrsig, abs_dsa_keys, None,
                             when2)
 
+    @unittest.skipIf(not dns.dnssec._have_pycrypto,
+                     "PyCrypto cannot be imported")
     def testAbsoluteDSABad(self):
         def bad():
             dns.dnssec.validate(abs_other_dsa_soa, abs_dsa_soa_rrsig,
similarity index 100%
rename from tests/flags.py
rename to tests/test_flags.py
similarity index 100%
rename from tests/generate.py
rename to tests/test_generate.py
similarity index 100%
rename from tests/message.py
rename to tests/test_message.py
similarity index 100%
rename from tests/name.py
rename to tests/test_name.py
similarity index 100%
rename from tests/namedict.py
rename to tests/test_namedict.py
similarity index 100%
rename from tests/ntoaaton.py
rename to tests/test_ntoaaton.py
similarity index 100%
rename from tests/resolver.py
rename to tests/test_resolver.py
similarity index 100%
rename from tests/rrset.py
rename to tests/test_rrset.py
similarity index 100%
rename from tests/set.py
rename to tests/test_set.py
similarity index 100%
rename from tests/tokenizer.py
rename to tests/test_tokenizer.py
similarity index 100%
rename from tests/update.py
rename to tests/test_update.py
similarity index 100%
rename from tests/zone.py
rename to tests/test_zone.py
diff --git a/tests/utest.py b/tests/utest.py
new file mode 100644 (file)
index 0000000..32c1d75
--- /dev/null
@@ -0,0 +1,8 @@
+import os.path
+import sys
+import unittest
+
+if __name__ == '__main__':
+    sys.path.insert(0, os.path.realpath('..'))
+    suites = unittest.defaultTestLoader.discover('.')
+    unittest.TextTestRunner(verbosity=2).run(suites)