In Python 2.7 you could use an additional parameter, msg
, to add information to the error message like this:
self.assertEqual(f.bar(t2), 2, msg='{0}, {1}'.format(t1, t2))
The official documentation is here.
More Related Contents:
- How do you test that a Python function throws an exception?
- python mocking raw input in unittests
- How unique is Python’s id()?
- TransactionManagementError “You can’t execute queries until the end of the ‘atomic’ block” while using signals, but only during Unit Testing
- Monkey patching a class in another module in Python
- Unittest setUp/tearDown for several tests
- Python Mocking a function from an imported module
- How to supply stdin, files and environment variable inputs to Python unit tests?
- How can one mock/stub python module like urllib
- Pytest fixture for a class through self not as method argument
- Mocking a class: Mock() or patch()?
- How to run Django’s test database only in memory?
- Python: Write unittest for console print
- Mock attributes in Python mock?
- Writing unit tests in Python: How do I start? [closed]
- Access self from decorator
- Python library ‘unittest’: Generate multiple tests programmatically [duplicate]
- How can I mock user input (from “input” in 3.x, or “raw_input” in 2.x) for a unit test?
- how to test if a variable is pd.NaT?
- How to test or mock “if __name__ == ‘__main__'” contents
- How to run django unit-tests on production database?
- how to share a variable across modules for all tests in py.test
- What is the difference between setUp() and setUpClass() in Python unittest?
- Unit testing a python app that uses the requests library
- Python Unit Testing: Automatically Running the Debugger when a test fails
- Pass a Python unittest if an exception isn’t raised
- pydev breakpoints not working
- How can I specify a database for Django Tests to use instead of having it build it every time?
- Can I “fake” a package (or at least a module) in python for testing purposes?
- How to mock a readonly property with mock?