Top "Python-unittest" questions

Python's standard library framework for testing.

Unit test: How to assert multiple calls of same method?

I have a method, which calls another method twice, with different arguments. class A(object): def helper(self, arg_one, …

python unit-testing python-unittest
Run a specific unit test function inside PyCharm IDE 5.0.4

I am trying to use PyCharm for unit testing (with unittest), and am able to make it work: the test …

python unit-testing pycharm python-unittest
Python unit test coverage for multiple modules

I searched for a long time and surprisingly found no satisfactory answer. I have multiple modules/files in my Python …

python unit-testing code-coverage python-unittest coverage.py
How to mock <ModelClass>.query.filter_by() in Flask-SqlAlchemy

In brief When testing a model class in Flask-SqlAlchemy, how can we mock the method .query.filter_by() so as …

python flask sqlalchemy mocking python-unittest
Instantiate Python unittest.TestCase with arguments

I would like to iterate over a list of items, and run an assertion on each of them. One example …

python-2.7 arguments test-suite python-unittest
How to compare two files as part of unittest, while getting useful output in case of mismatch?

As part of some Python tests using the unittest framework, I need to compare two relatively short text files, where …

python python-3.x python-unittest
How to mock a property

I'm asking how to mock a class property in a unit test using Python 3. I've tried the following, which makes …

python python-3.x pytest python-unittest python-mock
How to mock generators with mock.patch

I have gone through the page https://docs.python.org/3/library/unittest.mock-examples.html and i see that they have …

python generator nose python-unittest python-mock
Asserting that __init__ was called with right arguments

I'm using python mocks to assert that a particular object was created with the right arguments. This is how my …

python testing mocking python-unittest
How to mock a protected/private method in a tested method?

I have a Python Clas with 2 methods. The first, _getTemperature_() is protected and the second one is a public method. …

python unit-testing python-unittest python-unittest.mock