Questions tagged [nose]

Nose is an alternate Python unittest discovery and running process. It is intended to mimic the behavior of py.test as much as is reasonably possible.

Nose is an alternate unittest discovery and running process. It is intended to mimic the behavior of py.test as much as is reasonably possible.

Resources

1036 questions
20
votes
9 answers

Installed Nose but cannot use on command line

I installed Nose on a Mac OSX 10.10.5 with Python2.7.9 using easy_install. The installation appeared to be successful: Collecting nose Downloading nose-1.3.7-py2-none-any.whl (154kB) 100% |████████████████████████████████| 155kB 2.3MB/s…
AdjunctProfessorFalcon
  • 1,790
  • 6
  • 26
  • 62
20
votes
4 answers

Assert that two dictionaries are almost equal

I am trying to assert that two dictionaries are almost equal, but I can't seem to do that. Here is an example: >>> import nose.tools as nt >>> nt.assert_dict_equal({'a' : 12.4}, {'a' : 5.6 + 6.8}) Traceback (most recent call last): File "",…
Akavall
  • 82,592
  • 51
  • 207
  • 251
18
votes
2 answers

How do I run a single nosetest via setup.py in the python-active-directory module?

I am stubbornly trying to convert the Python module https://github.com/theatlantic/python-active-directory to Python 3. You can see my efforts here https://github.com/nbmorgan/python-active-directory/tree/master3. I have figured out the following…
Frobbit
  • 1,652
  • 17
  • 30
17
votes
2 answers

How to unit-test code that uses python-multiprocessing

I have some code that uses multiprocessing.Pool to fork workers and perform a task in parallel. I'm trying to find the right way to run unit tests of this code. Note I am not trying to test serial code test cases in parallel which I know packages…
Kyle
  • 2,814
  • 2
  • 17
  • 30
17
votes
3 answers

Run nosetests with warnings as errors?

When running nosetests from the command line, how do you specify that 'non-ignored' warnings should be treated as errors? By default, warnings are printed, but not counted as failures: [snip]/service/accounts/database.py:151: SADeprecationWarning:…
Jon-Eric
  • 16,977
  • 9
  • 65
  • 97
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
17
votes
5 answers

Nose test script with command line arguments

I would like to be able to run a nose test script which accepts command line arguments. For example, something along the lines: test.py import nose, sys def test(): # do something with the command line arguments print sys.argv if __name__…
D R
  • 21,936
  • 38
  • 112
  • 149
16
votes
3 answers

Debugging nosetest test in Pycharm doesn't show output

I'm trying to debug a test using nosetests in PyCharm. I need to stop at a breakpoint and do some interactive debugging using the PyCharm debug console. However, whenever I type anything at the debug console prompt, nothing is printed; I just get a…
LateCoder
  • 2,163
  • 4
  • 25
  • 44
16
votes
2 answers

Python 2.7 Unit test: Assert logger warning thrown

I'm trying to write a Unit Test for a piece of python code that raises a warning via logger.warn('...') under certain conditions. How do I assert that this warning has been logged? I noticed that assertLogged is not available until at least Python…
nlowe
  • 999
  • 4
  • 11
  • 26
15
votes
5 answers

How do I tell django-nose where my tests are?

I have my tests for a Django application in a tests directory: my_project/apps/my_app/ ├── __init__.py ├── tests │ ├── __init__.py │ ├── field_tests.py │ └── storage_tests.py ├── urls.py ├── utils.py └── views.py The Django test runner…
hekevintran
  • 22,822
  • 32
  • 111
  • 180
15
votes
5 answers

Mock flask.request in python nosetests

I'm writing test cases for code that is called via a route under Flask. I don't want to test the code by setting up a test app and calling a URL that hits the route, I want to call the function directly. To make this work I need to mock…
wizeowl
  • 466
  • 1
  • 6
  • 13
15
votes
3 answers

Python unit testing: make nose show failed assertions values

is it possible to show the assertion values that failed? It shows the traceback and what kind of exception was throw but it would more practical to know which values failed. Example: assert result.file == file AssertionError
Pickels
  • 33,902
  • 26
  • 118
  • 178
15
votes
2 answers

run nosetests in all subdirectories

I can run tests in workflow folder with nosetests: workflow maks$ nosetests .......... ---------------------------------------------------------------------- Ran 10 tests in 0.093s OK my tests live in test folder: workflow maks$ ls __pycache__ …
Maxim Yefremov
  • 13,671
  • 27
  • 117
  • 166
15
votes
3 answers

Import errors when running nosetests that I can't reproduce outside of nose

I'm running into a mysterious import error when using nosetests to run a test suite that I can't reproduce outside of the nose. Furthermore, the import error disappears when I skip a subset of the tests. Executive Summary: I am getting an import…
Alex Hasha
  • 153
  • 1
  • 5
15
votes
3 answers

How to exclude a file from coverage.py?

I use nosetest's coverage.py plugin. Is it somehow possible to exclude entire files or folders from the coverage report? My use case is having an external library in my project folder that obviously isn't covered by my test suite.
Nova
  • 2,623
  • 4
  • 26
  • 45