toofishes / python-pgpdump

PGP packet parser library
Other
55 stars 26 forks source link

setup.py missing test_suite support #11

Open eighthave opened 11 years ago

eighthave commented 11 years ago

The setup.py file does not include the test script. That is the standard interface for running the tests, and means that things that wrap setup.py will automatically run the tests. Such things include Debian packaging, pip, etc.

This patch adds test support while maintaining distutils compatibility:

diff --git a/setup.py b/setup.py
index 4bbca27..fc7eed2 100644
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,7 @@
-from distutils.core import setup
+try:
+    from setuptools import setup
+except ImportError:
+    from distutils.core import setup

 from pgpdump import __version__, __author__

@@ -21,5 +24,6 @@ setup(
     url = 'https://github.com/toofishes/python-pgpdump',
     keywords = 'pgp gpg rfc2440 rfc4880 crypto cryptography',
     classifiers = classifiers,
-    packages = ['pgpdump']
+    packages = ['pgpdump'],
+    test_suite='pgpdump.test'
 )
toofishes commented 11 years ago

How do most other packages handle this? This warning is rather annoying:

$ python2 setup.py check
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'test_suite'
  warnings.warn(msg)
eighthave commented 11 years ago

I haven't found a very clear standard in the way that people are incorporating tests. There is a pure distutils approach that I've seen, but it looked a lot more complicated. So I've used this approach. Having setuptools installed makes the warning go away.

abeluck commented 11 years ago

Fyi, @eighthave is creating a python-pgpdump package in Debian, hence this ;)

eighthave commented 11 years ago

its done and already in Debian: http://packages.qa.debian.org/p/python-pgpdump.html :-D

dkg commented 5 years ago

I'd like this to be merged as well, or at least something comparable to make it straightforward to run the tests in a standard way.