diff --git a/README.rst b/README.rst index 3fd0286..3ac562a 100644 --- a/README.rst +++ b/README.rst @@ -180,7 +180,7 @@ To run the tests, bootstrap Buildout and run this command: ... $ ./bin/test -We also use Tox_. It will run the tests for Python 2.6 and 2.7. +We also use Tox_. It will run the tests for Python 2.7 and 3.5. :: @@ -190,7 +190,7 @@ Requirements ------------ * Git >= 1.7 -* Python >= 2.6 +* Python >= 2.7 License ------- diff --git a/bootstrap.py b/bootstrap.py index 63aebb9..1e1fb19 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -20,9 +20,12 @@ $Id: bootstrap.py 102545 2009-08-06 14:49:47Z chrisw $ """ -import os, shutil, sys, tempfile, urllib2 +import os, shutil, sys, tempfile from optparse import OptionParser +from six.moves import reload_module, urllib + + tmpeggs = tempfile.mkdtemp() is_jython = sys.platform.startswith('java') @@ -32,7 +35,7 @@ parser.add_option("-v", "--version", dest="version", help="use a specific zc.buildout version") parser.add_option("-d", "--distribute", - action="store_true", dest="distribute", default=True, + action="store_true", dest="distribute", default=False, help="Use Disribute rather than Setuptools.") options, args = parser.parse_args() @@ -54,16 +57,22 @@ except ImportError: ez = {} if USE_DISTRIBUTE: - exec urllib2.urlopen('http://python-distribute.org/distribute_setup.py' - ).read() in ez + exec( + urllib.request.urlopen('http://python-distribute.org/distribute_setup.py' + ).read(), + ez, + ez) ez['use_setuptools'](to_dir=tmpeggs, download_delay=0, no_fake=True) else: - exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py' - ).read() in ez + exec( + urllib.request.urlopen('https://bootstrap.pypa.io/ez_setup.py' + ).read(), + ez, + ez) ez['use_setuptools'](to_dir=tmpeggs, download_delay=0) if to_reload: - reload(pkg_resources) + reload_module(pkg_resources) else: import pkg_resources diff --git a/setup.py b/setup.py index e5483d8..b8e6940 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,8 @@ version = '0.1.1' install_requires = [ - 'GitPython>=0.3.2RC1'] + 'GitPython>=0.3.2RC1', + 'six==1.10.0'] # Add argparse if less than Python 2.7 if sys.version_info[0] <= 2 and sys.version_info[1] < 7: @@ -26,8 +27,8 @@ 'Intended Audience :: Developers', 'Natural Language :: English', 'Operating System :: POSIX', - 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3.5', 'Topic :: Software Development :: Quality Assurance', 'Topic :: Software Development :: Version Control', 'Topic :: Text Processing' diff --git a/src/gitsweep/cli.py b/src/gitsweep/cli.py index 6b995b5..6d46bb1 100644 --- a/src/gitsweep/cli.py +++ b/src/gitsweep/cli.py @@ -4,6 +4,7 @@ from textwrap import dedent from git import Repo, InvalidGitRepositoryError +from six.moves import input from gitsweep.inspector import Inspector from gitsweep.deleter import Deleter @@ -142,7 +143,7 @@ def _sweep(self): if not args.force: sys.stdout.write('\nDelete these branches? (y/n) ') - answer = raw_input() + answer = input() if args.force or answer.lower().startswith('y'): sys.stdout.write('\n') for ref in ok_to_delete: diff --git a/src/gitsweep/tests/test_cli.py b/src/gitsweep/tests/test_cli.py index 9ddd6ce..cf0f2f3 100644 --- a/src/gitsweep/tests/test_cli.py +++ b/src/gitsweep/tests/test_cli.py @@ -135,7 +135,7 @@ def test_will_cleanup(self): self.make_commit() self.command('git merge branch{0}'.format(i)) - with patch('gitsweep.cli.raw_input', create=True) as ri: + with patch('gitsweep.cli.input', create=True) as ri: ri.return_value = 'y' (retcode, stdout, stderr) = self.gscommand('git-sweep cleanup') @@ -173,7 +173,7 @@ def test_will_abort_cleanup(self): self.make_commit() self.command('git merge branch{0}'.format(i)) - with patch('gitsweep.cli.raw_input', create=True) as ri: + with patch('gitsweep.cli.input', create=True) as ri: ri.return_value = 'n' (retcode, stdout, stderr) = self.gscommand('git-sweep cleanup') diff --git a/src/gitsweep/tests/testcases.py b/src/gitsweep/tests/testcases.py index fd9299c..7931293 100644 --- a/src/gitsweep/tests/testcases.py +++ b/src/gitsweep/tests/testcases.py @@ -6,7 +6,7 @@ from uuid import uuid4 as uuid from shutil import rmtree from shlex import split -from contextlib import contextmanager, nested +from contextlib import contextmanager from textwrap import dedent from mock import patch @@ -241,23 +241,20 @@ def gscommand(self, command): """ Runs the command with the given args. """ + exit_code = None args = split(command) self.cli.args = args[1:] - patches = ( - patch.object(sys, 'stdout'), - patch.object(sys, 'stderr')) - - with nested(*patches): + with patch.object(sys, 'stdout'), patch.object(sys, 'stderr'): stdout = sys.stdout stderr = sys.stderr try: self.cli.run() except SystemExit as se: - pass + exit_code = se.code stdout = ''.join([i[0][0] for i in stdout.write.call_args_list]) stderr = ''.join([i[0][0] for i in stderr.write.call_args_list]) - return (se.code, stdout, stderr) + return (exit_code, stdout, stderr) diff --git a/tox.ini b/tox.ini index e46ef65..f62524a 100644 --- a/tox.ini +++ b/tox.ini @@ -4,8 +4,8 @@ deps = mock commands = python -m gitsweep.scripts.test -[testenv:2.6] -basepython = python2.6 - [testenv:2.7] basepython = python2.7 + +[testenv:3.5] +basepython = python3.5