testing¶
Timing assertions for test suites (pytest plugin).
For teams building NICs, switches, firmware or time daemons: turn a timing requirement into a regression test::
from ntpstats.testing import assert_max_te, assert_stability_within
def test_boundary_clock_te(tmp_path):
log = run_my_bench(tmp_path) # produces a capture or a log
assert_max_te(log, 30e-9)
assert_stability_within(log, "masks/tdev.csv")
Every helper takes a path (any format ntpstats reads) or a
:class:~ntpstats.series.TimeSeries, and raises AssertionError with the
failing values. With ntpstats installed, pytest also gets the
timing_log fixture (a loader function).
assert_stability_within(source, mask, kind=None, **kw)
¶
Statistic (from the mask header, or kind) stays under the mask at every tau it covers.
assert_max_te(source, limit, input_is_te=False, **kw)
¶
max|TE| (local - reference) stays within limit seconds.
assert_time_error_within(source, limits, masks=(), input_is_te=False, **kw)
¶
All time-error limits (dict or limits file) and dTE_L MTIE/TDEV masks pass.
assert_audit_passes(source, limit, **cfg)
¶
The UTC traceability audit passes (bound within limit and enough coverage).
assert_bounds_valid(bounds, reference, max_violation_rate=0.0, **kw)
¶
Clock-error windows contain the reference's true time (violation rate within the allowance).
assert_no_events(source, kinds=('phase_step', 'frequency_change', 'delay_floor_change'), **kw)
¶
No steps, frequency changes or route changes (or the given kinds) in the log.
timing_log()
¶
Loader for timing logs: timing_log(path, fmt="auto", peer=None) -> TimeSeries.