From: Michael Orlitzky Date: Sat, 17 Sep 2022 00:07:05 +0000 (-0400) Subject: */*: reorganize for easy testing using setuptools or tox. X-Git-Tag: 0.0.1~24 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=d0b0eaf76d414da4b32313db94c1e38f29c0da60;p=djbdns-logparse.git */*: reorganize for easy testing using setuptools or tox. 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.) --- diff --git a/MANIFEST.in b/MANIFEST.in index 6ce0ed8..ed41b1b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1,2 @@ recursive-include doc * +recursive-include test * diff --git a/src/djbdns/common.py b/djbdns/common.py similarity index 100% rename from src/djbdns/common.py rename to djbdns/common.py diff --git a/src/djbdns/dnscache.py b/djbdns/dnscache.py similarity index 100% rename from src/djbdns/dnscache.py rename to djbdns/dnscache.py diff --git a/src/djbdns/io.py b/djbdns/io.py similarity index 95% rename from src/djbdns/io.py rename to djbdns/io.py index eee86cb..7c70bab 100644 --- a/src/djbdns/io.py +++ b/djbdns/io.py @@ -44,3 +44,6 @@ def parse_logfile(file : TextIO): friendly_line = line print(friendly_line) + + # Ensure that the pipe gets closed. + tai.communicate() diff --git a/src/djbdns/tinydns.py b/djbdns/tinydns.py similarity index 100% rename from src/djbdns/tinydns.py rename to djbdns/tinydns.py diff --git a/setup.py b/setup.py index c569f13..f3f664d 100644 --- 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 index 0000000..8c5ac13 --- /dev/null +++ b/test/__init__.py @@ -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 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