From: Bob Halley Date: Mon, 1 Sep 2014 00:40:54 +0000 (-0700) Subject: Overhaul test suite to allow testing in place. X-Git-Tag: v1.12.0-py3~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e3430cec7ce072322b16c2ca97c5ea506f14df31;p=thirdparty%2Fdnspython.git Overhaul test suite to allow testing in place. --- diff --git a/Makefile b/Makefile index 74469a32..882f6e65 100644 --- a/Makefile +++ b/Makefile @@ -54,3 +54,8 @@ kits: tags: find . -name '*.py' -print | etags - + +check: test + +test: + cd tests; make test diff --git a/dns/dnssec.py b/dns/dnssec.py index c1cd1cb7..2dd4a677 100644 --- a/dns/dnssec.py +++ b/dns/dnssec.py @@ -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 diff --git a/tests/Makefile b/tests/Makefile index cd6e4fa1..8c465dff 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -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 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 93% rename from tests/dnssec.py rename to tests/test_dnssec.py index f5fd54a2..98c47888 100644 --- a/tests/dnssec.py +++ b/tests/test_dnssec.py @@ -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, 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/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/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)