Evaluate pytest as a test framework

Description

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?

  • 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;

Environment

None

Activity

Show:
Ryan Luce
May 5, 2020, 5:04 PM

Resolved for lengthy time (at least six months), closing in bulk

Ziming Dong
March 19, 2020, 12:06 AM

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.

Kimyen Truong
June 28, 2019, 12:34 AM

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.

 

James Eddy
December 18, 2018, 3:52 AM

— 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.

Kimyen Truong
December 18, 2018, 1:11 AM
Done
Your pinned fields
Click on the next to a field label to start pinning.

Assignee

Kimyen Truong

Reporter

James Eddy

Validator

Ziming Dong