Frage

The title pretty much says it. I'm having problems connected to the change in the unittest python from python 2.5 to 2.7. When I run my test script with python

python _tester.py

it works fine. But when I try to use the coverage tool

coverage erase; coverage run _tester.py; coverage html -d html_cov_report

it crashes saying that assertRaisesRegexp is not an attribute of my subclass of TestCase. I discovered that this was because the coverage tool was using python 2.5 and unittest.TestCase.assertRaisesRegexp does not exist in 2.5.

Anyway, can somebody tell me how to change the python used by coverage?

EDIT: The egg for coverage is in /Library/Python/2.5/site-packages. Does that matter?

War es hilfreich?

Lösung

The coverage script should have a shebang that can be changed to the right version of python.

Edit: If you installed it in python 2.5, it is probably easiest to switch to installing using python 2.7.

Andere Tipps

I'm thinking of 4 options (with order of what should be done IMHO):

  1. You can install coverage under python2.7 and not python 2.5.
  2. I think this should be fixed if you run the coverage script using python 2.7: /path/to/python2.7 /path/to/coverage ..., assuming that python2.5 is the default one.
  3. use unittest2.
  4. you can change the default python to python 2.7 as i believe coverage script shebang should be /usr/bin/env python
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top