20
votes
3answers
4k views
How to generate dynamic (parametrized) unit tests in python?
I have some kind of test data and want to create an unit test for each item. My first idea was to do it like this:
import unittest
l = [["foo", "a", "a",], ["bar", "a", "b"], ["lee", "b", "b"]]
...
21
votes
7answers
4k views
Python unittest: Generate multiple tests programmatically? [duplicate]
Possible Duplicate:
How to generate dynamic (parametrized) unit tests in python?
I have a function to test, under_test, and a set of expected input/output pairs:
[
(2, 332),
(234, 99213),
...
103
votes
13answers
14k views
Where do the Python unit tests go?
If you're writing a library, or an app, where do the unit test files go?
It's nice to separate the test files from the main app code, but it's awkward to put them into a "tests" subdirectory inside ...
44
votes
6answers
11k views
How to run django's test database only in memory?
My django unit tests take a long time to run, so I'm looking for ways to speed that up. I'm considering installing an SSD, but I know that has its downsides too. Of course there are things I could ...
29
votes
7answers
13k views
How can one mock/stub python module like urllib
I need to test a function that needs to query a page on an external server using urllib.urlopen (it also uses urllib.urlencode). The server could be down, the page could change; I can't rely on it for ...
54
votes
7answers
15k views
Writing unit tests in Python: How do I start?
I completed my first proper project in Python and now my task is to write tests for it.
Since this is the first time I did a project, this is the first time I would be writing tests for it.
The ...
74
votes
6answers
8k views
Running unittest with typical test directory structure
The very common directory structure for even a simple Python module seems to be to separate the unit tests into their own test directory:
new_project/
antigravity/
antigravity.py
...
58
votes
1answer
8k views
Python nose vs. unittest [closed]
What are the advantages and disadvantages of Python's nose library versus unittest.
15
votes
3answers
3k views
Python's unittest and dynamic creation of test cases [duplicate]
Possible Duplicate:
How to generate dynamic (parametrized) unit tests in python?
Is there a way to dynamically create unittest test cases? I have tried the following..
class ...
7
votes
3answers
3k views
pydev breakpoints not working
I am working on a project using python 2.7.2, sqlalchemy 0.7, unittest, eclipse 3.7.2 and pydev 2.4. I am setting breakpoints in python files (unit test files), but they are completely ignored ...
83
votes
11answers
8k views
Python - doctest vs. unittest
I'm trying to get started with unit testing in Python and I was wondering if someone could inform me of the advantages and disadvantages of doctest and unittest. What conditions would you use each ...
14
votes
2answers
5k views
I need a sample of python unit testing sqlalchemy model with nose
Can someone show me how to write unit tests for sqlalchemy model I created using nose.
I just need one simple example.
Thanks.
8
votes
2answers
2k views
How can I unit test responses from the webapp WSGI application in Google App Engine?
I'd like to unit test responses from the Google App Engine webapp.WSGIApplication, for example request the url '/' and test that the responses status code is 200, using GAEUnit. How can I do this?
...
17
votes
2answers
3k views
Commit in git only if tests pass
I've recently started using git, and also begun unit testing (using Python's unittest module). I'd like to run my tests each time I commit, and only commit if they pass.
I'm guessing I need to use ...
18
votes
7answers
12k views
Outputting data from unit test in python
If I'm writing unit tests in python (using the unittest module), is it possible to output data from a failed test, so I can examine it to help deduce what caused the error? I am aware of the ability ...