Urgent.News

What's breaking now, across thousands of outlets.

Tech

My CI hadn't run a single one of those tests in two months and stayed green the whole time

I added a dependency to a test helper and forgot to declare it in the dev extra. Locally it was already installed, so everything passed. In CI it wasn't, and the tests that needed it did not fail. They skipped. Skips exit 0. The checkmark stayed green for two months. Why it skips instead of failing The pattern is one line, it's in every codebase, and it's usually correct: aiosqlite = pytest .…

The source material discusses an issue where a continuous integration (CI) system reported a suite of tests as passing for two months, even though the tests were missing a crucial dependency. The dependency was not explicitly declared in the development environment, but it was already installed locally. As a result, the tests using this dependency would skip instead of failing, leading to a misleading green checkmark.

The author added a guard in the form of a pytest sessionfinish hook, which raised an exit status if the number of collected tests fell below a minimum threshold. This guard helped identify when tests had stopped running unexpectedly. The author also suggested adding the -rs option to pytest, which prints the reason for every skipped test, making it easier to identify the cause of the issue.

To fix the problem, the author added the missing dependency to the project's optional dependencies list. They also removed the importorskip line for the dependency, as it was a misrepresentation of the requirement. By properly declaring the dependency, the CI system would no longer skip the tests and would report the failure correctly.

The key takeaway from the story is that a seemingly green CI build can hide underlying issues, such as missing dependencies. Properly declaring and testing dependencies is essential to ensure the reliability and trustworthiness of the CI system. The author emphasizes the importance of using the pytest --collect-only option with the -rs flag to identify skipped tests and understand the reasons behind them.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

My OSS Projects: Piral

This is the third post in my "My Open-Source Projects" series, where I go through some of the OSS projects I started or maintain and tell you the story behind them.

Jour 5/100 · 60 minutes

Compréhension de la différence entre listes et tableaux. Déclaration et manipulation d'une List implémentée par une ArrayList. Une pause déjeuner bien utilisée !

More from Wednesday 23 September →