]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
overhaul test system
authorBob Halley <halley@dnspython.org>
Sat, 31 May 2014 18:07:58 +0000 (11:07 -0700)
committerBob Halley <halley@dnspython.org>
Sat, 31 May 2014 18:07:58 +0000 (11:07 -0700)
20 files changed:
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 94% 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_grange.py [moved from tests/grange.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_rdtypeanyloc.py [moved from tests/rdtypeanyloc.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 edbe479672081916f46e811af26fdfa96813c016..f1d70cea25af3e5e27d8621a3a7e85b34c8670dc 100644 (file)
@@ -405,9 +405,11 @@ 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
 
 try:
     import ecdsa
index 6ab444f451e2097c4d2f723b5ab20168640657e8..1524552e0e91e044339e30165b0ba25da5a7cfa3 100644 (file)
@@ -20,7 +20,4 @@ PYTHON=python
 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 94%
rename from tests/dnssec.py
rename to tests/test_dnssec.py
index edb028b536b04994f5658880e2f1c7ba0faac3c8..cbbd3e22efff5e3a8be8874571668cb48691ea06 100644 (file)
@@ -133,22 +133,32 @@ abs_ecdsa384_soa_rrsig = dns.rrset.from_text('example.', 86400, 'IN', 'RRSIG',
 
 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.failUnlessRaises(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,
@@ -159,10 +169,14 @@ class DNSSECValidatorTestCase(unittest.TestCase):
         ds = dns.dnssec.make_ds(abs_dnspython_org, sep_key, 'SHA256')
         self.failUnless(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,
@@ -178,13 +192,13 @@ class DNSSECValidatorTestCase(unittest.TestCase):
         self.failUnless(ds == example_ds_sha256)
 
     @unittest.skipIf(not dns.dnssec._have_ecdsa,
-                     "python ECDSA can not be imported")
+                     "python ECDSA cannot be imported")
     def testAbsoluteECDSA256Good(self):
         dns.dnssec.validate(abs_ecdsa256_soa, abs_ecdsa256_soa_rrsig,
                             abs_ecdsa256_keys, None, when3)
 
     @unittest.skipIf(not dns.dnssec._have_ecdsa,
-                     "python ECDSA can not be imported")
+                     "python ECDSA cannot be imported")
     def testAbsoluteECDSA256Bad(self):
         def bad():
             dns.dnssec.validate(abs_other_ecdsa256_soa, abs_ecdsa256_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/grange.py
rename to tests/test_grange.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)