Commits

Ned Batchelder  committed 5d07456

Create coverage-X.Y aliases also. Closes #111.

  • Participants
  • Parent commits 9faf7f2

Comments (0)

Files changed (4)

 - Embarrassingly, the `[xml] output=' setting in the .coveragerc file simply
   didn't work.  Now it does.
 
-- When installing, now in addition to creating a "coverage" command, a
-  "coverage2" or "coverage3" command will be created, depending on whether you
-  are installing in Python 2.x or 3.x.  Thanks, Julian Berman.
+- When installing, now in addition to creating a "coverage" command, two new
+  aliases are also installed.  A "coverage2" or "coverage3" command will be
+  created, depending on whether you are installing in Python 2.x or 3.x.
+  A "coverage-X.Y" command will also be created corresponding to your specific
+  version of Python.  Closes `issue 111`.
 
 - On Windows, files are now reported in their correct case, fixing `issue 89`_
   and `issue 203`_.
 - Other minor bugs fixed: `issue 153`_.
 
 .. _issue 89: https://bitbucket.org/ned/coveragepy/issue/89/on-windows-all-packages-are-reported-in
+.. _issue 111: https://bitbucket.org/ned/coveragepy/issue/111/when-installing-coverage-with-pip-not
 .. _issue 139: https://bitbucket.org/ned/coveragepy/issue/139/easy-check-for-a-certain-coverage-in-tests
 .. _issue 143: https://bitbucket.org/ned/coveragepy/issue/143/omit-doesnt-seem-to-work-in-coverage
 .. _issue 153: https://bitbucket.org/ned/coveragepy/issue/153/non-existent-filename-triggers
 When you install coverage.py, a command-line script simply called ``coverage``
 is placed in your Python scripts directory.  To help with multi-version
 installs, it will also create either a ``coverage2`` or ``coverage3`` alias,
-depending on the version of Python you're using.
+and a ``coverage-X.Y`` alias, depending on the version of Python you're using.
+For example, when installing on Python 2.7, you will be able to use
+``coverage``, ``coverage2``, or ``coverage-2.7`` on the command line.
 
 Coverage has a number of commands which determine the action performed:
 
     devstat = "5 - Production/Stable"
 classifier_list.append("Development Status :: " + devstat)
 
-# Install a script as "coverage", and as "coverage[23]"
+# Install a script as "coverage", and as "coverage[23]", and as
+# "coverage-2.7" (or whatever).
 scripts = [
     'coverage = coverage:main',
-    'coverage%d = coverage:main' % sys.version_info[0],
+    'coverage%d = coverage:main' % sys.version_info[:1],
+    'coverage-%d.%d = coverage:main' % sys.version_info[:2],
     ]
 
 # Create the keyword arguments for setup()

File test/test_process.py

                 # about 5.
                 self.assertGreater(data.summary()['os.py'], 50)
 
-    def test_version_aliases(self):
+
+class AliasedCommandTests(CoverageTest):
+    """Tests of the version-specific command aliases."""
+
+    def test__major_version_works(self):
+        # "coverage2" works on py2
         cmd = "coverage%d" % sys.version_info[0]
         out = self.run_command(cmd)
         self.assertIn("Code coverage for Python", out)
+
+    def test_wrong_alias_doesnt_work(self):
+        # "coverage3" doesn't work on py2
         badcmd = "coverage%d" % (5 - sys.version_info[0])
         out = self.run_command(badcmd)
         self.assertNotIn("Code coverage for Python", out)
 
+    def test_specific_alias_works(self):
+        # "coverage-2.7" works on py2.7
+        cmd = "coverage-%d.%d" % sys.version_info[:2]
+        out = self.run_command(cmd)
+        self.assertIn("Code coverage for Python", out)
+
 
 class FailUnderTest(CoverageTest):
     """Tests of the --fail-under switch."""