Top "Python-unittest" questions

Python's standard library framework for testing.

Display python unittest results in nice, tabular form

I am writing a Pythonic tool which validates the correctness of a certain system. Each validation is written as a …

python unit-testing testing python-unittest test-reporting
Python returns MagicMock object instead of return_value

I have a python file a.py which contains two classes A and B. class A(object): def method_a(…

python python-unittest magicmock
patching a class yields "AttributeError: Mock object has no attribute" when accessing instance attributes

The Problem Using mock.patch with autospec=True to patch a class is not preserving attributes of instances of that …

python unit-testing attributes mocking python-unittest
Python3.6 error: ModuleNotFoundError: No module named 'src'

I know similar questions have been asked before... But I had a quick doubt... I have been following this link: …

python-3.6 python-unittest
How to send requests with JSONs in unit tests

I have code within a Flask application that uses JSONs in the request, and I can get the JSON object …

python json flask python-unittest
What is the difference between setUp() and setUpClass() in Python unittest?

What is the difference between setUp() and setUpClass() in the Python unittest framework? Why would setup be handled in one …

python unit-testing python-unittest
How do you mock patch a python class and get a new Mock object for each instantiation?

OK, I know this is mentioned in the manual, and probably has to do with side_effect and/or return_…

python mocking python-unittest python-mock
python mock assert_called_with

I'm trying to understand the assert_called_with within mock but the code I wrote throws some error. import os …

python python-unittest python-mock python-unittest.mock
Python: Write unittest for console print

Function foo prints to console. I want to test the console print. How can I achieve this in python? Need …

python python-2.7 unit-testing console python-unittest
Trying to implement python TestSuite

I have two test cases (two different files) that I want to run together in a Test Suite. I can …

python unit-testing regression-testing test-suite python-unittest