lundi 14 décembre 2020

A proper way to import library from the same git repository in python

I have an infrastructure project, which uses testinfra (plugin to pytest), and it's called through Molecule (an Ansible testing framework) with heavy Ansible integration (hosts from inventory, variables, etc).

The placement and structure of those tests is hardwired by layers of policy (both from testinfra and Molecule).

All those tests have some common code for processing test data and interacting with a target application. I've placed it into a module, but I have trouble to find a proper way to import this module.

  • It's not an 'external' module, so there is no pip, and it can change wildly with every next commit.
  • It's not a conftest style code, as it's a true module (with __init__, and even has own tests somewhere inside of the module)
  • The real tests are run inside a container with freshly cloned git (the usual for CI), so I could install the module into the container filesystem but it looks silly, as modifying filesystem of the running container is pure sign of "container smell" (breaking the best practices for containers).
  • Or I can mangle PYTHON_PATH before running anything. Which is ugly, has a high WTF content and not obvious to fix when broken.

May be there is a better way?

Aucun commentaire:

Enregistrer un commentaire