diff --git a/CHANGES.rst b/CHANGES.rst index 523cfa9..bee9f9c 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -8,6 +8,8 @@ Changelog * Friendlier error message when an external command cannot be found (`issue #21 `__). * Add suggestion pattern for `.coveragerc`. +* Python 2.6 support + (`issue #22 `__). 0.17 (2013-10-10) diff --git a/setup.py b/setup.py index 5b7f30d..7d6bff3 100755 --- a/setup.py +++ b/setup.py @@ -1,7 +1,12 @@ #!/usr/bin/env python -import os, re, ast, email.utils +import os, re, ast, email.utils, sys from setuptools import setup +if sys.version_info < (2, 6): + sys.exit("Python 2.6 or newer is required for check-manifest") + +PY26 = (sys.version_info[:2] == (2, 6)) + here = os.path.dirname(__file__) with open(os.path.join(here, 'README.rst')) as readme: @@ -40,6 +45,7 @@ 'License :: uhh, dunno', 'Operating System :: OS Independent', 'Programming Language :: Python', + 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.2', 'Programming Language :: Python :: 3.3', @@ -51,8 +57,8 @@ py_modules=['check_manifest'], zip_safe=False, test_suite='tests.test_suite', - install_requires=[], - tests_require=['mock'], + install_requires=['argparse'] if PY26 else [], + tests_require=['mock'] + (['unittest2'] if PY26 else []), entry_points={ 'console_scripts': [ 'check-manifest = check_manifest:main', diff --git a/tests.py b/tests.py index 1f3c087..13a1c89 100644 --- a/tests.py +++ b/tests.py @@ -5,7 +5,10 @@ import sys import tempfile import textwrap -import unittest +try: + import unittest2 as unittest # Python 2.6 +except ImportError: + import unittest try: from cStringIO import StringIO # Python 2.x @@ -50,11 +53,14 @@ def test_run_no_such_program(self): def test_copy_files(self): from check_manifest import copy_files actions = [] - with mock.patch('os.path.isdir', lambda d: d in ('b', '/dest/dir')), \ - mock.patch('os.makedirs', lambda d: actions.append('makedirs %s' % d)), \ - mock.patch('os.mkdir', lambda d: actions.append('mkdir %s' % d)), \ - mock.patch('shutil.copy2', lambda s, d: actions.append('cp %s %s' % (s, d))): - copy_files(['a', 'b', 'c/d/e'], '/dest/dir') + with mock.patch('os.path.isdir', lambda d: d in ('b', '/dest/dir')): + with mock.patch('os.makedirs', + lambda d: actions.append('makedirs %s' % d)): + with mock.patch('os.mkdir', + lambda d: actions.append('mkdir %s' % d)): + with mock.patch('shutil.copy2', + lambda s, d: actions.append('cp %s %s' % (s, d))): + copy_files(['a', 'b', 'c/d/e'], '/dest/dir') self.assertEqual( actions, [ @@ -385,12 +391,14 @@ def tearDown(self): shutil.rmtree(self.tmpdir) def _run(self, *command): - try: - subprocess.check_output(command, stderr=subprocess.STDOUT) - except subprocess.CalledProcessError as e: + p = subprocess.Popen(command, stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + stdout, stderr = p.communicate() + rc = p.wait() + if rc: print(' '.join(command)) - print(e.output) - raise + print(stdout) + raise subprocess.CalledProcessError(rc, command[0], output=stdout) def _create_file(self, filename): assert not os.path.isabs(filename) diff --git a/tox.ini b/tox.ini index 27566e8..115651d 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py27,py32,py33,pypy + py26,py27,py32,py33,pypy [testenv] deps = @@ -8,6 +8,11 @@ deps = commands = python setup.py test -q +[testenv:py26] +deps = + {[testenv]deps} + unittest2 + [testenv:coverage] deps = {[testenv]deps}