What is preferred testing methodology among python contributors?

I’m working on some Python code which I hope will be welcomed by python users and even work its way into the standard library.
Part of having it be useful is to have tests as part of the code. If it is going to be adopted by the community, obviously they will want a way of verifying that the code is correct, and that it remains correct if is later revised.

Of the many testing frameworks that are available (only a few of which I’ve actually seen), I’d like a suggestion as to one to use for my new package.

pytest and unittest would be the most popular choices. Maybe you’d like to check out more in Awesome-Python

I’m inclined to go with pytest. I use Visual Studio, and I see that it knows about pytest, but I haven’t yet learned how to use it to run tests.

I am at a loss about what is a good way to write my test cases and arrange them in my project.

I can see these objectives:

  • Somebody besides myself should be able to decide if the code works well enough to be published to the community at large.
  • Easy to tell if the test cases cover enough of the functionality.
  • Easy to update the tests, and run the tests, as the package evolves.
  • The package can be used/installed by a naive end user with or without the testing.
  • Other considerations that haven’t occurred to me.

As such, I’d like suggestions and/or examples of how testing is implemented, and the code is organized, in major projects.

I’m particularly curious about how Cpython itself, and the standard library, are tested and their correctness judged.

Maybe a good starting point: Running and writing tests