Pytest Ethos

Date: 2026 01-January 08

where do tests run? mostly in ci on a remote server or mostly locally?

should every function be included in tests? how do you not over design tests and slow down development

Testing is a balancing act. If you test everything, you never ship; if you test nothing, you ship broken code.


Where do tests run?

In a professional workflow, they run in both places, but they serve different purposes:

Image of continuous integration workflow diagram


Should every function be included?

No. Striving for "100% Code Coverage" is often a trap that leads to brittle tests.2


How to avoid over-designing (and slowing down)

To keep development fast, follow these three rules:

1. The "Pyramid" Strategy

Write many small, fast Unit Tests (testing one function in isolation) and only a few heavy Integration Tests (testing the CLI, the DB, and the network all at once).

2. Mock the "Expensive" stuff

Since your new design calls the dworshak CLI, a real test would require installing that CLI and setting up a real vault every time. That is slow and "heavy."

3. Test for Value, not Volume

Ask yourself: "If I change this code later, will this test catch a real bug, or will it just break because the test is too specific?"


A "Low-Overhead" Next Step

Since dworshak-access is so lightweight, I recommend starting with three tests in a single file:

  1. Success: Call get_secret and get a string back (Mocked).

  2. Missing CLI: Verify a RuntimeError happens if dworshak isn't installed.

  3. Bad Item: Verify a KeyError happens if the CLI returns a non-zero exit code.

Would you like me to write the code for those three specific tests using pytest and unittest.mock?