summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJP <jpellerin@gmail.com>2012-04-09 07:31:37 -0700
committerJP <jpellerin@gmail.com>2012-04-09 07:31:37 -0700
commit551ffe92ebd8f8d0c834779bb808e2e0db15b2a0 (patch)
treeb1d60a8405a3dc90bb93133fb8c87e6d2ddc6b4c
parent3983ae3636eb286c0610f113e77356435d686018 (diff)
parent12740cadf14414f0abbc7ef1b58a83e66e973988 (diff)
downloadnose-551ffe92ebd8f8d0c834779bb808e2e0db15b2a0.tar.gz
Merge pull request #508 from erosennin/master
Add support for converting the sources with 2to3 to nosetests setuptools command
-rw-r--r--doc/index.rst5
-rw-r--r--nose/commands.py27
2 files changed, 27 insertions, 5 deletions
diff --git a/doc/index.rst b/doc/index.rst
index eeb1805..68d16eb 100644
--- a/doc/index.rst
+++ b/doc/index.rst
@@ -60,6 +60,11 @@ nose supports python3. Building from source on python3 requires
have distribute installed, ``python3 setup.py install`` will install
it via distribute's bootstrap script.
+Additionally, if your project is using `2to3
+<http://docs.python.org/library/2to3.html>`_, ``python3 setup.py nosetests``
+command will automatically convert your sources with 2to3 and then the
+tests with python 3.
+
.. warning ::
nose itself supports python 3, but many 3rd-party plugins do not!
diff --git a/nose/commands.py b/nose/commands.py
index b819b38..3b43ed0 100644
--- a/nose/commands.py
+++ b/nose/commands.py
@@ -113,11 +113,27 @@ else:
def run(self):
"""ensure tests are capable of being run, then
run nose.main with a reconstructed argument list"""
- self.run_command('egg_info')
+ if getattr(self.distribution, 'use_2to3', False):
+ # If we run 2to3 we can not do this inplace:
- # Build extensions in-place
- self.reinitialize_command('build_ext', inplace=1)
- self.run_command('build_ext')
+ # Ensure metadata is up-to-date
+ self.reinitialize_command('build_py', inplace=0)
+ self.run_command('build_py')
+ bpy_cmd = self.get_finalized_command("build_py")
+ build_path = bpy_cmd.build_lib
+
+ # Build extensions
+ self.reinitialize_command('egg_info', egg_base=build_path)
+ self.run_command('egg_info')
+
+ self.reinitialize_command('build_ext', inplace=0)
+ self.run_command('build_ext')
+ else:
+ self.run_command('egg_info')
+
+ # Build extensions in-place
+ self.reinitialize_command('build_ext', inplace=1)
+ self.run_command('build_ext')
if self.distribution.install_requires:
self.distribution.fetch_build_eggs(
@@ -126,7 +142,8 @@ else:
self.distribution.fetch_build_eggs(
self.distribution.tests_require)
- argv = ['nosetests']
+ ei_cmd = self.get_finalized_command("egg_info")
+ argv = ['nosetests', ei_cmd.egg_base]
for (option_name, cmd_name) in self.option_to_cmds.items():
if option_name in option_blacklist:
continue