Python: Unit Tests Tool broken for old repls, random git-python package, it still uses legacy configuration

The Unit Tests tool on python repls, by default, tries to install a random git-python package. Installation will fail on old python repls that use python 3.8 because of dependency resolving. (This heavily affects forks of old repls in education.)
Even on newer python repls, certain look-alike packages can cause errors or unwanted package installation.

Problem part 1:
This problem is caused by the fact that for the relative common import main, such as import main or from main import *, UPM’s import guessing will find git-python as a package that needs to be installed. The unit test tool imports main in the setup (this cannot be changed), which inevitably installs git-python, sometimes breaking unit tests.

Problem part 2:
The official (but currently undocumented) configuration for disabling UPM’s import guessing or automatic package installation is described here:

The legacy configuration does not actually work anymore, and is not present in newer repls.
However, the Unit Test tool still relies on this older configuration (and this will actually work). This means that the current workaround for this problem uses old configuration. While this is not terrible for old repls as the configuration is already present, newer repls must have the code added. Plus, the Unit Test behavior will not align with Run behavior this way. The configuration code is provided here:

Expected behavior:

  1. UPM does not guess git-python as a package for import main
  2. Unit Tests use the new (undocumented but working) configuration instead of the legacy configuration.

Steps to reproduce:
Create a python repl using the official template. Open the Unit Tests tool and create a test. Run the tests. In the console, git-python is being added (because of the Unit Tests setup). (kill 1 in shell to cancel installation)
Also, put import main in If you press run, it will also try to install git-python.