Numerous Python packages use PyTest extensively.
apt install a package that depends on
python-pytest is also installed.
The system version of a package is typically several minor versions behind for stable Linux distros like Ubuntu.
To find which specific package is responsible for a package being installed, use a command like:
apt-cache rdepends --installed python-pytest
which reveals that
are requiring this old pytest version.