From: Bob Halley Date: Sat, 31 May 2014 18:07:58 +0000 (-0700) Subject: overhaul test system X-Git-Tag: v1.12.0~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c8e17fc02a2d3ebbee3e7c34cd7828858e13fe57;p=thirdparty%2Fdnspython.git overhaul test system --- diff --git a/dns/dnssec.py b/dns/dnssec.py index edbe4796..f1d70cea 100644 --- a/dns/dnssec.py +++ b/dns/dnssec.py @@ -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 diff --git a/tests/Makefile b/tests/Makefile index 6ab444f4..1524552e 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -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 diff --git a/tests/bugs.py b/tests/test_bugs.py similarity index 100% rename from tests/bugs.py rename to tests/test_bugs.py diff --git a/tests/dnssec.py b/tests/test_dnssec.py similarity index 94% rename from tests/dnssec.py rename to tests/test_dnssec.py index edb028b5..cbbd3e22 100644 --- a/tests/dnssec.py +++ b/tests/test_dnssec.py @@ -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, diff --git a/tests/flags.py b/tests/test_flags.py similarity index 100% rename from tests/flags.py rename to tests/test_flags.py diff --git a/tests/generate.py b/tests/test_generate.py similarity index 100% rename from tests/generate.py rename to tests/test_generate.py diff --git a/tests/grange.py b/tests/test_grange.py similarity index 100% rename from tests/grange.py rename to tests/test_grange.py diff --git a/tests/message.py b/tests/test_message.py similarity index 100% rename from tests/message.py rename to tests/test_message.py diff --git a/tests/name.py b/tests/test_name.py similarity index 100% rename from tests/name.py rename to tests/test_name.py diff --git a/tests/namedict.py b/tests/test_namedict.py similarity index 100% rename from tests/namedict.py rename to tests/test_namedict.py diff --git a/tests/ntoaaton.py b/tests/test_ntoaaton.py similarity index 100% rename from tests/ntoaaton.py rename to tests/test_ntoaaton.py diff --git a/tests/rdtypeandclass.py b/tests/test_rdtypeandclass.py similarity index 100% rename from tests/rdtypeandclass.py rename to tests/test_rdtypeandclass.py diff --git a/tests/rdtypeanyloc.py b/tests/test_rdtypeanyloc.py similarity index 100% rename from tests/rdtypeanyloc.py rename to tests/test_rdtypeanyloc.py diff --git a/tests/resolver.py b/tests/test_resolver.py similarity index 100% rename from tests/resolver.py rename to tests/test_resolver.py diff --git a/tests/rrset.py b/tests/test_rrset.py similarity index 100% rename from tests/rrset.py rename to tests/test_rrset.py diff --git a/tests/set.py b/tests/test_set.py similarity index 100% rename from tests/set.py rename to tests/test_set.py diff --git a/tests/tokenizer.py b/tests/test_tokenizer.py similarity index 100% rename from tests/tokenizer.py rename to tests/test_tokenizer.py diff --git a/tests/update.py b/tests/test_update.py similarity index 100% rename from tests/update.py rename to tests/test_update.py diff --git a/tests/zone.py b/tests/test_zone.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 index 00000000..32c1d753 --- /dev/null +++ b/tests/utest.py @@ -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)