Skip to content
academia.sh

Course Intermediate

Python Projects: Packaging and Testing

By the end of this course

Start course

01

Environment and Dependencies

The rationale for isolation and the install lifecycle, project metadata and locking, resolution strategies producing separate sets from the same declaration, and switching between interpreter versions.

  1. 01 Virtual Environments The same resolution gives five distinct outcomes across six installs on a shared site, and the project sees the set it resolved itself on only two of the six orders; on an isolated site the number drops to one, and all six orders install the same set.
  2. 02 Dependency Declaration The same declaration gives 2 distinct version sets when the resolution strategy changes, and a lock file drops the number to 1; when the registry view also changes, four installs made from the declaration give 3 distinct sets while the locked four stay at one set.
  3. 03 Package Managers When packages require each other, the same declaration gives 4 distinct sets under four strategies, and only 3 of those are consistent; once constraints tighten, two backtracking strategies find no solution and the consistent-set count drops to 0, while a lock file brings all four down to 1.
  4. 04 Version Management The same declaration gives 2 distinct version sets across three rig interpreter versions; of nine installs made from lock files produced on one interpreter, 6 are accepted and 3 rejected, and the same lock gives 1 distinct outcome on a fixed interpreter but produces one rejection across three interpreters.

02

Testing

Unit test writing styles, taking repetition out of a test with fixtures and parametrization, isolating external dependencies, making examples testable, and what coverage says and does not say.

  1. 01 Test Frameworks A framework does four jobs, and only one of them produces the verdict: the same three cases give 1 distinct outcome across two writing styles, while the same file gives 3 distinct outcomes in found-test terms across three discovery rules, and the report stays the same across all three.
  2. 02 Fixtures and Parametrization A five-test suite passes 4/5 in writing order and 5/5 in the other two, giving 2 distinct verdicts by order; when a fixture rebuilds shared state fresh for every test, the count drops to 1, and when it is built at the session level, the count drops to 1 again, but this time at 4/5.
  3. 03 Mock Objects The same test reaching an external source gives 3 distinct outcomes across three modes, dropping to 1 with a mock object; but a mock drifted from the registry also gives 1 distinct outcome and passes because the expectation is written alongside it, 2 distinct outcomes stand between it and the real source, and a contract test finds the drift in a single package.
  4. 04 Doctests Seven of twelve documentation claims go stale from a single format change; in the prose-heavy writing, 4 of them turn audible and 3 stay silent, and once two claims get converted to examples, the audible count rises to 6 and only the rationale is left — the same staleness, 2 distinct outcomes.
  5. 05 Coverage Measurement A three-test suite covers 8 of 8 lines (1.0000), takes 6 of 6 branches, and passes 3/3; against that, in one of four input combinations the actual behavior deviates from the oracle and the test suite runs exactly that call — coverage counts where the code ran, not what the test looked at.

03

Quality and Publishing

Automated format and rule checking, verification across multiple environments, distribution formats and build systems, submission to a package registry with version marking, and generating documentation from source.

  1. 01 Formatters and Linters The same function's six separate forms give six separate source texts but a single parse tree; the formatter reduces the six texts to 1 distinct outcome, drops the linter's finding-set count from 5 to 1, but leaves the remaining 6 findings and the single call that deviates from the oracle untouched.
  2. 02 Multi-Environment Testing The same seven-test team gives 4 distinct decisions across 18 runs on the axes of three interpreters, two resolutions, and three orders; the lock file drops runs to 9 and decisions to 3, the fixture to 3 and 2, and the remaining two decisions are the real environment difference itself.
  3. 03 Packaging Nine builds made from the same source across three directory states and three inclusion rules give 5 distinct contents; the explicit list drops this number to 1, only using sorted order together with a source-derived stamp unifies the archive digest, and when the build step runs drops install from 3 distinct outcomes to 1.
  4. 04 Publishing Nine publish attempts produce 9 accepted and 2 silent changes in an overwritable registry, 7 accepted and 2 rejected in an immutable one; the same lock file gives 2 distinct installs in the first registry, and a lock that also writes the digest catches both of those two mismatches and stops the install.
  5. 05 Documentation Documentation generated from four source versions gives 2 distinct outcomes and stale-signature count stays at 0 across all four, while in the handwritten document it sits between 2 and 3; generation unifies the signature, it does not unify the claim in the summary text, and only a runnable example catches that claim.

Start typing to search.

↑↓ Esc navigate · open · close