Found reviewing #80, in that PR's own change.
assemble() reads the census run date with census.pop("_as_of"), which removes the key from the caller's dictionary. Calling assemble() twice with the same census object raises KeyError: '_as_of' on the second call.
first call OK; census still has _as_of? False
SECOND CALL FAILS: KeyError '_as_of'
main() loads a fresh dictionary each run, so the shipped path is unaffected. The test suite is not so lucky: FleetPageTests builds self.census once in setUp and test_new_admission_cannot_silently_omit_card_or_graph_node calls render() twice. That test passes today only because its second call raises ValueError from the membership check before reaching the pop. Any reordering of those checks, or any new test that renders twice, turns into a confusing KeyError about a key the author never touched.
A function that takes a parsed document should not consume it. Reading the field and filtering the metadata key out of the Mech entries costs nothing and removes the trap.
Fixing in #80.
Found reviewing #80, in that PR's own change.
assemble()reads the census run date withcensus.pop("_as_of"), which removes the key from the caller's dictionary. Callingassemble()twice with the same census object raisesKeyError: '_as_of'on the second call.main()loads a fresh dictionary each run, so the shipped path is unaffected. The test suite is not so lucky:FleetPageTestsbuildsself.censusonce insetUpandtest_new_admission_cannot_silently_omit_card_or_graph_nodecallsrender()twice. That test passes today only because its second call raisesValueErrorfrom the membership check before reaching the pop. Any reordering of those checks, or any new test that renders twice, turns into a confusingKeyErrorabout a key the author never touched.A function that takes a parsed document should not consume it. Reading the field and filtering the metadata key out of the Mech entries costs nothing and removes the trap.
Fixing in #80.