The always interesting Earthmover folks have developed third-wheel, a neat tool to be able to install multiple versions of the same library in a python virtual environment.
The use case is described in this blog post:
TL;DR: use this tool if you want to test different versions in the same pytest, e.g. write a file with one version and read with the other and vice versa.
The blog post also namechecks Hypothesis which is a useful python library for generating python test cases to more thoroughly exercise your testing functions.