If you're trying to get pytest running for old packages you may encounter failures due to ResourceWarning or DeperactionWarning errors
Those can be easily resolved by executing pytest as follows:
pytest -v tests -W ignore::ResourceWarning -W ignore::DeprecationWarning
In your nixpkgs package that would be
checkPhase = ''
pytest -v tests -W ignore::ResourceWarning -W ignore::DeprecationWarning
'';