How do you write tests for the argparse portion of a python module?
I have a Python module that uses the argparse library. How do I write tests for that section of the code base?
I have a Python module that uses the argparse library. How do I write tests for that section of the code base?
I have a function with a decorator that I’m trying test with the help of the Python Mock library. I’d like to use mock.patch to replace the real decorator with a mock ‘bypass’ decorator which just calls the function.
Is there a way in Python unittest to set the order in which test cases are run?
tl;dr
Does Python reuse ids? How likely it is that two objects with non overlapping lifetime will get the same id?
How can I make it so unit tests in Python (using unittest) are run in the order in which they are specified in the file?
EDIT: switched to a better example, and clarified why this is a real problem.
I have a console program written in Python. It asks the user questions using the command:
I’m working with a module written by someone else. I’d like to monkey patch the __init__ method of a class defined in the module. The examples I have found showing how to do this have all assumed I’d be calling the class myself (e.g. Monkey-patch Python class). However, this is not the case. In my case the class is initalised within a function in another module. See the (greatly simplified) example below:
In our team, we define most test cases like this: