Files
troupe-standup/wizard-work/beam/_smoke_intervals.py
T

34 lines
1.1 KiB
Python

"""Smoke: three cells over `intervals.py`, the module BESIDE this file.
Q163. This script landed with `sys.path.insert(0, "/root/troupe-standup/
wizard-work/beam")`, so it graded whatever that host directory held. Measured
on 2026-11-03: a copy of this script in a scratch lane whose `intervals.py` was
replaced by a stand-in returning `[]`, `-1` and `[]` still printed
`intervals smoke OK`, rc 0 -- it had read the host copy. It now binds its own
directory, and asserts which file it read, so that reading cannot recur
silently.
"""
import sys
from pathlib import Path
HERE = Path(__file__).resolve().parent
sys.path.insert(0, str(HERE))
import intervals # noqa: E402
from intervals import merge, total_covered, find_gaps # noqa: E402
assert Path(intervals.__file__).resolve() == HERE / "intervals.py", \
"graded %s, not the module beside this file" % intervals.__file__
def main():
# smoke
assert merge([(1, 4), (3, 6), (8, 10)]) == [(1, 6), (8, 10)]
assert total_covered([(1, 4), (3, 6)]) == 5
assert find_gaps([(1, 3), (5, 7)], 0, 8) == [(0, 1), (3, 5), (7, 8)]
print("intervals smoke OK")
if __name__ == "__main__":
main()