From d0b0eaf76d414da4b32313db94c1e38f29c0da60 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 16 Sep 2022 20:07:05 -0400 Subject: [PATCH] */*: 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.) --- MANIFEST.in | 1 + {src/djbdns => djbdns}/common.py | 0 {src/djbdns => djbdns}/dnscache.py | 0 {src/djbdns => djbdns}/io.py | 3 +++ {src/djbdns => djbdns}/tinydns.py | 0 setup.py | 7 ++++--- test/__init__.py | 15 +++++++++++++++ tox.ini | 6 ++++++ 8 files changed, 29 insertions(+), 3 deletions(-) rename {src/djbdns => djbdns}/common.py (100%) rename {src/djbdns => djbdns}/dnscache.py (100%) rename {src/djbdns => djbdns}/io.py (95%) rename {src/djbdns => djbdns}/tinydns.py (100%) create mode 100644 test/__init__.py create mode 100644 tox.ini 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 -- 2.43.2