Top "Python-unittest" questions

Python's standard library framework for testing.

Python Unit Test : How to unit test the module which contains database operations?

I am using pymysql client library to connect to the real database. I have a function in module, where I …

python python-2.7 unit-testing python-unittest python-unittest.mock
How to stub time.sleep() in Python unit testing

I want to make a stub to prevent time.sleep(..) to sleep to improve the unit test execution time. What …

python class time constructor python-unittest
Recursive unittest discover

I have a package with a directory "tests" in which I'm storing my unit tests. My package looks like: . ├── LICENSE ├── …

python python-2.7 python-unittest
Python unitest - Use variables defined in module and class level setup functions, in tests

I am doing Python unit testing using nosetests to experiment with Python class and module fixtures, to have minimal setup …

python unit-testing oop nose python-unittest
Python Mock - How to get the return of a MagicMock as if it was a normal method

For example: import mock class MyClass(object): def foo(self, x, y, z): return (x, y, z) class TestMyClass(TestCase) @…

python unit-testing mocking python-unittest python-mock
How to stop all tests from inside a test or setUp using unittest?

I'm extending the python 2.7 unittest framework to do some function testing. One of the things I would like to do …

python testing automated-tests functional-testing python-unittest
Assert that logging has been called with specific string

I'm trying to use unittest to test some functions of a SimpleXMLRPCServer I made. Togethere with Mock, I'm now trying …

python-2.7 unit-testing logging mocking python-unittest
Python SQLAlchemy mocking

this is a method that I made chained DB query calls. import math def get_all_keys(): db_session = DBSession() …

python unit-testing sqlalchemy python-unittest python-unittest.mock
Test Redirection In Flask with Python Unittest

I am currently trying to write some unit tests for my Flask application. In many of my view functions (such …

python unit-testing flask python-unittest
How do I test if a certain log message is logged in a Django test case?

I want to ensure that a certain condition in my code causes a log message to be written to the …

python django unit-testing testing python-unittest