Skip to content
Advertisement

Tag: python-unittest

Python Mock Patch multiple methods in a class

Im trying to patch multiple methods in a class. Here is my simplified set up Hook.py is defined as HookTransfer.py defined as I want to mock the methods get_key and get_value in the Hook class. The following works i.e. prints New_Key and New_Value However this does not. It prints <MagicMock name=’Hook().get_key()’ id=’4317706896′> and <MagicMock name=’Hook().get_value()’ id=’4317826128′> Intuitively it seems like

How to send requests with JSON in unit tests

I have code within a Flask application that uses JSONs in the request, and I can get the JSON object like so: This has been working fine, however I am trying to create unit tests using Python’s unittest module and I’m having difficulty finding a way to send a JSON with the request. This gives me: Flask seems to have

Python unittest not recognizing tests

I’m trying to learn how to use the unittest framework in python. I keep getting the message below when I run my file containing the tests. I’ve searched here and elsewhere and can’t figure out why it is not recognizing the tests. Each test starts with test and the other portions of the unittest seem to match what the documentation

Advertisement