r/madeinpython • • 1d ago

A renamed Python folder should not silently retire its architecture test

You rename a package, update its imports, and the tests are green. An architecture test that still points at the old directory can look green for a less useful reason: it isn't checking any files.

I maintain ArchUnitPython. Its file rules report an empty selection as a violation by default. I verified that with a cycle rule pointing at a missing directory, alongside a real dependency rule with both passing and failing imports.

This is useful for long-lived pytest suites where the architecture checks might be edited less often than the code they protect. A stale selector becomes something to fix instead of a rule that quietly disappears.

There is an option for intentionally empty selections, but keep that permission deliberate. A generated directory that is absent in one build is a different situation from a package path that nobody updated after a refactor.

The library gives you normal assertions through assert_passes, so this fits into the same test run as your behavioral checks.

Source: https://github.com/LukasNiessen/ArchUnitPython

1 Upvotes

0 comments sorted by