Skip to content
Advertisement

Tag: unit-testing

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. Answer Yeah, they have pretty extensive support for this in the docs. When running your code, the coverage run command will

Python import src modules when running tests

My source files are located under src and my test files are located under tests. When I want to run a test file, say python myTest.py, I get an import error: “No module named ASourceModule.py”. How do I import all the modules from source needed to run my tests? Answer You need to add that directory to the path: Maybe

Proper way to test Django signals

I’m trying to test sent signal and it’s providing_args. Signal triggered inside contact_question_create view just after form submission. My TestCase is something like: Is this the proper way to test this signal? Any better ideas? Answer I’ve resolved the problem by myself. I think that the best solution is following:

Python unit test with base and sub class

I currently have a few unit tests which share a common set of tests. Here’s an example: The output of the above is: Is there a way to rewrite the above so that the very first testCommon is not called? EDIT: Instead of running 5 tests above, I want it to run only 4 tests, 2 from the SubTest1 and

Advertisement