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.

390 questions
20
votes
8 answers

Can I restrict nose coverage output to directory (rather than package)?

My SUT looks like: foo.py bar.py tests/__init__.py [empty] tests/foo_tests.py tests/bar_tests.py tests/integration/__init__.py [empty] tests/integration/foo_tests.py tests/integration/bar_tests.py When I run nosetests --with-coverage, I get details…
Daryl Spitzer
  • 143,156
  • 76
  • 154
  • 173
20
votes
3 answers

Get IP Address when testing flask application through nosetests

My application depends on request.remote_addr which is None when i run tests through nosetests which uses app.test_client().post('/users/login', ....). How can I emulate an IP (127.0.0.1 works fine) when I run tests? I've tried setting environment…
moodh
  • 2,661
  • 28
  • 42
18
votes
3 answers

how do i redirect the output of nosetests to a textfile?

I've tried "nosetests p1.py > text.txt" and it is not working. What is the proper way to pipe this console output?
iCodeLikeImDrunk
  • 17,085
  • 35
  • 108
  • 169
18
votes
3 answers

How to run specific test in Nose2

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…
Tomáš Ehrlich
  • 6,546
  • 3
  • 25
  • 31
17
votes
4 answers

Stop nosetests from printing logging information?

How do I prevent nosetests from interspersing logging output inside the output from its tests? I've just adding logging to my Django code like this: import logging logger = logging.getLogger(__name__) def home_page(request, template): device =…
Jim
  • 13,430
  • 26
  • 104
  • 155
17
votes
2 answers

A Nose plugin to specify the order of unit test execution

I have a desire to use Nose for an over the wire integration test suite. However, the order of execution of some of these tests is important. That said, I thought I would toss together a quick plugin to decorate a test with the order I want it…
Jesse
  • 8,223
  • 6
  • 49
  • 81
15
votes
2 answers

How to test that a function is called within a function with nosetests

I'm trying to set up some automatic unit testing for a project. I have some functions which, as a side effect occasionally call another function. I want to write a unit test which tests that the second function gets called but I'm stumped. Below is…
msvalkon
  • 11,887
  • 2
  • 42
  • 38
14
votes
2 answers

How to output coverage XML with nosetests?

I'm trying to output the coverage XML of my nosetests so they show up on Hudson. The line I'm executing is: nosetests --with-gae -v --all-modules --with-xunit --with-coverage I see the coverage output in the console, but there's no xml file…
Cuga
  • 17,668
  • 31
  • 111
  • 166
13
votes
3 answers

Python nosetests skip certain Tests

I am working on tests for a web application written in python. Suppose I have 5 tests in my test_login.py module. Every single test is a Class. There is often one, base test that extends TestFlow class, which is our predefined test class. And then…
koleS
  • 1,263
  • 6
  • 30
  • 46
12
votes
4 answers

nosetests framework: how to pass environment variables to my tests?

I have a test suite that gets executed as a part of a larger build framework, written in Python. Some of the tests require parameters, which I want to pass using environment variables. Apparently the nosetests runner has an env parameter, which does…
Mihai
  • 2,835
  • 2
  • 28
  • 36
12
votes
1 answer

Timeout on tests with nosetests

I'm setting up my nosetests environment but can't seem to get the timeout to work properly. I would like to have an x second (say 2) timeout on each test discovered by nose. I tried the following: nosetests --processes=-1…
JustMe
  • 237
  • 4
  • 7
12
votes
4 answers

Testing IPython Notebooks

I'm starting to use IPython notebooks to document some of my code with interactive usage examples. In order to avoid having the documentation get too far out of date from the code, I'd like the code in the notebook to get executed on a regular…
DMack
  • 1,117
  • 1
  • 10
  • 14
11
votes
2 answers

Anyone know how nosetest's -m, -i and -e work?

I am trying to get nosetests to identify my tests but it is not running any of my tests properly. I have the following file structure Project +----Foo/ +----__init__.py +----bar.py +----test/ +----__init__.py …
sasker
  • 2,221
  • 2
  • 21
  • 26
11
votes
3 answers

How to organize and run unittests and functional tests separately using nosetests

I have the following typical python project file structure packageA +----subpackage1 +----classa.py +----subpackage2 +----classb.py +----test +----subpackage1 +----classa_test.py …
sasker
  • 2,221
  • 2
  • 21
  • 26
11
votes
5 answers

Is there a way to get python's nose module to work the same in __main__ and on the command line?

I'm not sure of how to get the nose module's __main__ handler to work. I have this at the end of my test module: if __name__ == "__main__": import nose nose.main() Which gives…
PerilousApricot
  • 633
  • 1
  • 7
  • 19
1
2
3
25 26