Evaluate pytest as a test framework
Questions to answer:
How to mock an object?
How to mock a function call?
How to inspect the function input?
How to evaluate the number of times a function was called?
How to setup and teardown?
How to prepare data for test cases?
How to share setup between test modules? For integration tests?
How to test that an exception is raised?
What error will be printed when a test fails? In comparison?
Found the answer here: https://docs.pytest.org/en/latest/index.html
What are the framework dependencies?
Found the dependencies here: https://github.com/pytest-dev/pytest/blob/master/setup.py
What is the migration process from nose to pytest?
As one of pytest feature:
Can run unittest (including trial) and nose test suites out of the box;
Resolved for lengthy time (at least six months), closing in bulk
We did not move forward with porting all tests in the main python client to work with pytest as of version 2.0 so I am removing the fixVersion tag.
I’ve been using pytest in my refactor work for the Synapse Python client. So far, fixture is very nice way to shorten test setup.
About testing code in document, pytest support doctest:
I don’t know how I feel about interactive Python code block in our docs. Every Python client command requires setting up a connection to Synapse. This may not be the right uses of doctest.
Regardless, I will be using pytest in the Python client code base.
— as promised, links to some test suites from my projects (they’re definitely not exemplars of great Python testing, but should at least provide a broad range of examples):
Also, I think I might have mentioned “extensions” for pytest, but they’re technically called “plug-ins” (you can find a glimpse here, but there a lot more if you search for them).
I’ll try to follow up with some more answers/references to your questions above.