diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst --- a/Doc/library/unittest.rst +++ b/Doc/library/unittest.rst @@ -291,16 +291,28 @@ used from the command line. The basic co python -m unittest discover .. note:: As a shortcut, ``python -m unittest`` is the equivalent of ``python -m unittest discover``. If you want to pass arguments to test discovery the ``discover`` sub-command must be used explicitly. +.. note:: The ``pyunit`` script can be used as a shorthand for + ``python -m unittest`` or ``python -m unittest discover``:: + + pyunit + pyunit -v + pyunit -s vendor/tests + pyunit -p '*_test.py' + pyunit -h + + .. versionadded:: 3.4 + + The ``discover`` sub-command has the following options: .. program:: unittest discover .. cmdoption:: -v, --verbose Verbose output diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -961,16 +961,18 @@ bininstall: altbininstall -rm -f $(DESTDIR)$(BINDIR)/idle3 (cd $(DESTDIR)$(BINDIR); $(LN) -s idle$(VERSION) idle3) -rm -f $(DESTDIR)$(BINDIR)/pydoc3 (cd $(DESTDIR)$(BINDIR); $(LN) -s pydoc$(VERSION) pydoc3) -rm -f $(DESTDIR)$(BINDIR)/2to3 (cd $(DESTDIR)$(BINDIR); $(LN) -s 2to3-$(VERSION) 2to3) -rm -f $(DESTDIR)$(BINDIR)/pyvenv (cd $(DESTDIR)$(BINDIR); $(LN) -s pyvenv-$(VERSION) pyvenv) + -rm -f $(DESTDIR)$(BINDIR)/pyunit + (cd $(DESTDIR)$(BINDIR); $(LN) -s pyunit-$(VERSION) pyunit) # Install the manual page maninstall: @for i in $(MANDIR) $(MANDIR)/man1; \ do \ if test ! -d $(DESTDIR)$$i; then \ echo "Creating directory $$i"; \ $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \ diff --git a/Tools/scripts/pyunit b/Tools/scripts/pyunit new file mode 100755 --- /dev/null +++ b/Tools/scripts/pyunit @@ -0,0 +1,11 @@ +from sys import argv + +__unittest = True + +from unittest.main import main, USAGE_AS_MAIN + +if '-s' in argv or '-p' in argv or '-t' in argv: + argv.insert(1, 'discover') + +main.USAGE = USAGE_AS_MAIN +main(module=None) diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -2069,17 +2069,17 @@ class PyBuildInstallLib(install_lib): class PyBuildScripts(build_scripts): def copy_scripts(self): outfiles, updated_files = build_scripts.copy_scripts(self) fullversion = '-{0[0]}.{0[1]}'.format(sys.version_info) minoronly = '.{0[1]}'.format(sys.version_info) newoutfiles = [] newupdated_files = [] for filename in outfiles: - if filename.endswith(('2to3', 'pyvenv')): + if filename.endswith(('2to3', 'pyvenv', 'pyunit')): newfilename = filename + fullversion else: newfilename = filename + minoronly log.info('renaming {} to {}'.format(filename, newfilename)) os.rename(filename, newfilename) newoutfiles.append(newfilename) if filename in updated_files: newupdated_files.append(newfilename) @@ -2137,14 +2137,15 @@ def main(): # The struct module is defined here, because build_ext won't be # called unless there's at least one extension module defined. ext_modules=[Extension('_struct', ['_struct.c'])], # If you change the scripts installed here, you also need to # check the PyBuildScripts command above, and change the links # created by the bininstall target in Makefile.pre.in scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3", - "Tools/scripts/2to3", "Tools/scripts/pyvenv"] + "Tools/scripts/2to3", "Tools/scripts/pyvenv", + "Tools/scripts/pyunit",] ) # --install-platlib if __name__ == '__main__': main()