]> gitweb.michael.orlitzky.com - djbdns-logparse.git/commitdiff
*/*: reorganize for easy testing using setuptools or tox.
authorMichael Orlitzky <michael@orlitzky.com>
Sat, 17 Sep 2022 00:07:05 +0000 (20:07 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Sat, 17 Sep 2022 00:07:05 +0000 (20:07 -0400)
Now running either,

  $ python setup.py test

or

  $ tox

will execute the test suite. (The former is deprecated, but is easier
for now, and most importantly doesn't require tox.)

MANIFEST.in
djbdns/common.py [moved from src/djbdns/common.py with 100% similarity]
djbdns/dnscache.py [moved from src/djbdns/dnscache.py with 100% similarity]
djbdns/io.py [moved from src/djbdns/io.py with 95% similarity]
djbdns/tinydns.py [moved from src/djbdns/tinydns.py with 100% similarity]
setup.py
test/__init__.py [new file with mode: 0644]
tox.ini [new file with mode: 0644]

index 6ce0ed812b69a43dcc2324a9609632a4faefb373..ed41b1b8032424f7f7b5aab3888b5bc34c179fba 100644 (file)
@@ -1 +1,2 @@
 recursive-include doc *
+recursive-include test *
similarity index 100%
rename from src/djbdns/common.py
rename to djbdns/common.py
similarity index 100%
rename from src/djbdns/dnscache.py
rename to djbdns/dnscache.py
similarity index 95%
rename from src/djbdns/io.py
rename to djbdns/io.py
index eee86cb3d4b99e888065e6384a4cf5438a3a2b30..7c70bab3debcf2b78ad43e18146488740cdf1c4e 100644 (file)
@@ -44,3 +44,6 @@ def parse_logfile(file : TextIO):
                 friendly_line = line
 
         print(friendly_line)
+
+    # Ensure that the pipe gets closed.
+    tai.communicate()
similarity index 100%
rename from src/djbdns/tinydns.py
rename to djbdns/tinydns.py
index c569f13f62e2673ecf2d189adfa9bad2f9150534..f3f664d50d324d03aeb91b813d9948249199d2fa 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,4 @@
-from distutils.core import setup
+from setuptools import setup
 
 setup(
     name         = 'djbdns-logparse',
@@ -9,7 +9,8 @@ setup(
     keywords     = 'djbdns, tinydns, dnscache',
     scripts      = ['bin/djbdns-logparse'],
     packages     = ['djbdns'],
-    package_dir  = {'djbdns': 'src/djbdns'},
+    package_dir  = {'djbdns': 'djbdns'},
     description  = 'Convert tinydns and dnscache logs to human-readable form',
-    license      = 'doc/LICENSE'
+    test_suite   = 'test.build_suite',
+    license      = 'AGPLv3+'
 )
diff --git a/test/__init__.py b/test/__init__.py
new file mode 100644 (file)
index 0000000..8c5ac13
--- /dev/null
@@ -0,0 +1,15 @@
+def build_suite():
+    from doctest import DocTestSuite
+    from unittest import TestSuite
+    import djbdns.common
+    import djbdns.dnscache
+    import djbdns.io
+    import djbdns.tinydns
+
+    tests = TestSuite()
+    tests.addTests(DocTestSuite(djbdns.common))
+    tests.addTests(DocTestSuite(djbdns.dnscache))
+    tests.addTests(DocTestSuite(djbdns.io))
+    tests.addTests(DocTestSuite(djbdns.tinydns))
+
+    return tests
diff --git a/tox.ini b/tox.ini
new file mode 100644 (file)
index 0000000..7ae3c95
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,6 @@
+[testenv]
+commands =
+    python -m doctest -v djbdns/common.py
+    python -m doctest -v djbdns/dnscache.py
+    python -m doctest -v djbdns/io.py
+    python -m doctest -v djbdns/tinydns.py