Questions tagged [nosetests]

nosetests is the the script name for running Python [nose] testing, a package for automated unit tests based on simple asserts and running all test*() functions in test*.py.

nosetests is the main script for running tests with automatic discover.

See documentation.

393 questions
154
votes
6 answers

How do I run a single test with Nose in Pylons

I have a Pylons 1.0 app with a bunch of tests in the test/functional directory. I'm getting weird test results and I want to just run a single test. The nose documentation says I should be able to pass in a test name at the command line but I get…
Ben
  • 9,591
  • 9
  • 32
  • 40
147
votes
5 answers

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

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 this. class MyTest(TestCase): …
Frankie Ribery
  • 10,943
  • 11
  • 46
  • 62
120
votes
13 answers

How to assert output with nosetest/unittest in python?

I'm writing tests for a function like next one: def foo(): print 'hello world!' So when I want to test this function the code will be like this: import sys from foomodule import foo def test_foo(): foo() output =…
Pedro Valencia
  • 1,217
  • 2
  • 9
  • 3
107
votes
6 answers

How do I specify a single test in a file with nosetests?

I have a file called test_web.py containing a class TestWeb and many methods named like test_something(). I can run every test in the class like so: $ nosetests test_web.py…
opstastic
  • 1,172
  • 2
  • 7
  • 6
57
votes
2 answers

How to use nose's assert_raises?

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?
user1544624
  • 847
  • 1
  • 7
  • 15
54
votes
3 answers

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

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…
Bodhi
  • 1,427
  • 1
  • 13
  • 20
52
votes
5 answers

Disabling Python nosetests

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): …
Richard Dorman
  • 21,020
  • 12
  • 42
  • 48
47
votes
9 answers

Problems using nose in a virtualenv

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…
Ryan
  • 1,277
  • 1
  • 12
  • 18
41
votes
3 answers

List all Tests Found by Nosetest

I use nosetests to run my unittests and it works well. I want to get a list of all the tests nostests finds without actually running them. Is there a way to do that?
Cristian
  • 38,467
  • 25
  • 81
  • 98
40
votes
3 answers

Excluding abstractproperties from coverage reports

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…
Demian Brecht
  • 20,087
  • 3
  • 37
  • 44
36
votes
7 answers

"No source for code" message in Coverage.py

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.…
Matt Norris
  • 7,408
  • 11
  • 51
  • 88
36
votes
2 answers

How to run a single test or single TestCase with django-nose?

With Django's normal test runner, you can drill down to run tests in a specific app, a specific subclass of TestCase, or a specific test within a specific subclass of TestCase. E.g.: ./manage.py test myapp.MyTestCase.test_something However,…
GDorn
  • 7,551
  • 6
  • 33
  • 34
33
votes
10 answers

Installing nose using pip, but bash doesn't recognize command on mac

I'm trying to install nose on my computer for the Learn Python the Hard Way tutorial, but can't seem to get it to work. I'm using pip to install: $ pip install nose And I get back: Requirement already satisfied (use --upgrade to upgrade): nose in…
Zubin
  • 383
  • 1
  • 3
  • 7
30
votes
3 answers

How do you run nosetest from pycharm?

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.
Nick Sonneveld
  • 3,246
  • 4
  • 34
  • 47
28
votes
2 answers

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

Is there a way to time the execution time of individual Python tests which are run by nosetests ?
kamal
  • 9,015
  • 28
  • 92
  • 148
1
2 3
26 27