nosetests

How to run specific test in Nose2

How to run specific test in Nose2 Question: In previous version of Nose testing framework, there were several ways to specify only a subset of all tests: nosetests test.module nosetests another.test:TestCase.test_method nosetests a.test:TestCase nosetests /path/to/test/file.py:test_function http://nose.readthedocs.org/en/latest/usage.html#selecting-tests However, I can’t find any information about similar test selection in Nose2. There’s a mention in docs about different …

Total answers: 3

How to use nose's assert_raises?

How to use nose's assert_raises? Question: I’ve searched for documentation, but couldn’t find any. There were a couple that didn’t explain much. Can someone explain to me Nose’s assert_raises(what should I put here?) function and how to use it? Asked By: user1544624 || Source Answers: The assert_raises() function tests to make sure a function call …

Total answers: 2

Excluding abstractproperties from coverage reports

Excluding abstractproperties from coverage reports Question: I have an abstract base class along the lines of: class MyAbstractClass(object): __metaclass__ = ABCMeta @abstractproperty def myproperty(self): pass But when I run nosetests (which coverage) on my project, it complains that the property def line is untested. It can’t actually be tested (AFAIK) as instantiation of the abstract …

Total answers: 3

pdb.set_trace() causing frozen nosetests, does not drop into debugger

pdb.set_trace() causing frozen nosetests, does not drop into debugger Question: I’m running a suite of tests (.py files) using nosetests. Using a classic import pdb; pdb.set_trace() the nosetests run just never completes. It just hangs right where the breakpoint has been set, but never drops into the pdb debugger. Any ideas why this would be? …

Total answers: 3

nosetests is capturing the output of my print statements. How to circumvent this?

nosetests is capturing the output of my print statements. How to circumvent this? Question: When I type $ nosetests -v mytest.py all my print outputs are captured when all tests pass. I want to see print outputs even everything passes. So what I’m doing is to force an assertion error to see the output, like …

Total answers: 5

How do I measure the execution time of python unit tests with nosetests?

How do I measure the execution time of python unit tests with nosetests? Question: Is there a way to time the execution time of individual Python tests which are run by nosetests ? Asked By: kamal || Source Answers: You might try the nose plug-in posted here: https://github.com/mahmoudimus/nose-timer (or available via pip / PyPi). You …

Total answers: 2

How do you run nosetest from pycharm?

How do you run nosetest from pycharm? Question: How do you execute nosetest from pycharm to run all unit tests? I know that pycharm supports python’s unittest and py.test and that they will properly support nosetests in pycharm 1.1 but I was wondering if there was a work around. Asked By: Nick Sonneveld || Source …

Total answers: 3

"No source for code" message in Coverage.py

"No source for code" message in Coverage.py Question: I ran a build last night, successfully. I got up this morning and ran another without changing any configuration or modifying any source code. Now my build is failing with the message “No source for code” when running my nosetests with coverage. NoSource: No source for code: …

Total answers: 10

Disabling Python nosetests

Disabling Python nosetests Question: When using nosetests for Python it is possible to disable a unit test by setting the test function’s __test__ attribute to false. I have implemented this using the following decorator: def unit_test_disabled(): def wrapper(func): func.__test__ = False return func return wrapper @unit_test_disabled def test_my_sample_test() #code here … However, this has the …

Total answers: 5

Problems using nose in a virtualenv

Problems using nose in a virtualenv Question: I am unable to use nose (nosetests) in a virtualenv project – it can’t seem to find the packages installed in the virtualenv environment. The odd thing is that i can set test_suite = ‘nose.collector’ in setup.py and run the tests just fine as python setup.py test but …

Total answers: 9