summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2014-08-31 17:40:54 -0700
committerBob Halley <halley@dnspython.org>2014-08-31 17:40:54 -0700
commite3430cec7ce072322b16c2ca97c5ea506f14df31 (patch)
treec8444e1b42c414f9eb89e893abed6ebc8709e423
parent889e1e7342b54687f491c4521c4329ef1feb8b8f (diff)
downloaddnspython-e3430cec7ce072322b16c2ca97c5ea506f14df31.tar.gz
Overhaul test suite to allow testing in place.
-rw-r--r--Makefile5
-rw-r--r--dns/dnssec.py2
-rw-r--r--tests/Makefile5
-rw-r--r--tests/test_bugs.py (renamed from tests/bugs.py)0
-rw-r--r--tests/test_dnssec.py (renamed from tests/dnssec.py)14
-rw-r--r--tests/test_flags.py (renamed from tests/flags.py)0
-rw-r--r--tests/test_generate.py (renamed from tests/generate.py)0
-rw-r--r--tests/test_message.py (renamed from tests/message.py)0
-rw-r--r--tests/test_name.py (renamed from tests/name.py)0
-rw-r--r--tests/test_namedict.py (renamed from tests/namedict.py)0
-rw-r--r--tests/test_ntoaaton.py (renamed from tests/ntoaaton.py)0
-rw-r--r--tests/test_rdtypeandclass.py (renamed from tests/rdtypeandclass.py)0
-rw-r--r--tests/test_resolver.py (renamed from tests/resolver.py)0
-rw-r--r--tests/test_rrset.py (renamed from tests/rrset.py)0
-rw-r--r--tests/test_set.py (renamed from tests/set.py)0
-rw-r--r--tests/test_tokenizer.py (renamed from tests/tokenizer.py)0
-rw-r--r--tests/test_update.py (renamed from tests/update.py)0
-rw-r--r--tests/test_zone.py (renamed from tests/zone.py)0
-rw-r--r--tests/utest.py8
19 files changed, 30 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 74469a3..882f6e6 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 c1cd1cb..2dd4a67 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 cd6e4fa..8c465df 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
index 906e0fd..906e0fd 100644
--- a/tests/bugs.py
+++ b/tests/test_bugs.py
diff --git a/tests/dnssec.py b/tests/test_dnssec.py
index f5fd54a..98c4788 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
index 41372cd..41372cd 100644
--- a/tests/flags.py
+++ b/tests/test_flags.py
diff --git a/tests/generate.py b/tests/test_generate.py
index fd78925..fd78925 100644
--- a/tests/generate.py
+++ b/tests/test_generate.py
diff --git a/tests/message.py b/tests/test_message.py
index 603b4ac..603b4ac 100644
--- a/tests/message.py
+++ b/tests/test_message.py
diff --git a/tests/name.py b/tests/test_name.py
index c125a15..c125a15 100644
--- a/tests/name.py
+++ b/tests/test_name.py
diff --git a/tests/namedict.py b/tests/test_namedict.py
index 91fd397..91fd397 100644
--- a/tests/namedict.py
+++ b/tests/test_namedict.py
diff --git a/tests/ntoaaton.py b/tests/test_ntoaaton.py
index 92ccc81..92ccc81 100644
--- a/tests/ntoaaton.py
+++ b/tests/test_ntoaaton.py
diff --git a/tests/rdtypeandclass.py b/tests/test_rdtypeandclass.py
index 69b77f4..69b77f4 100644
--- a/tests/rdtypeandclass.py
+++ b/tests/test_rdtypeandclass.py
diff --git a/tests/resolver.py b/tests/test_resolver.py
index 2f09463..2f09463 100644
--- a/tests/resolver.py
+++ b/tests/test_resolver.py
diff --git a/tests/rrset.py b/tests/test_rrset.py
index f4b2b2e..f4b2b2e 100644
--- a/tests/rrset.py
+++ b/tests/test_rrset.py
diff --git a/tests/set.py b/tests/test_set.py
index a6607b8..a6607b8 100644
--- a/tests/set.py
+++ b/tests/test_set.py
diff --git a/tests/tokenizer.py b/tests/test_tokenizer.py
index 8bc33c0..8bc33c0 100644
--- a/tests/tokenizer.py
+++ b/tests/test_tokenizer.py
diff --git a/tests/update.py b/tests/test_update.py
index 471a798..471a798 100644
--- a/tests/update.py
+++ b/tests/test_update.py
diff --git a/tests/zone.py b/tests/test_zone.py
index 67fc2ae..67fc2ae 100644
--- a/tests/zone.py
+++ b/tests/test_zone.py
diff --git a/tests/utest.py b/tests/utest.py
new file mode 100644
index 0000000..32c1d75
--- /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)