Numerous Python packages use
apt install a package that depends on
python-pytest is also installed.
This is annoying because 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.