Reference
Testing
Run your module under pytest with a fake you control: while25.use().
Nothing above needs While25 to import, so a module is an ordinary class:
import while25
def test_it_logs_on_a_down_bar():
seen = []
class FakeCtx:
params = {}
def log(self, msg, level="info"): seen.append(msg)
fake = FakeCtx()
with while25.use(fake): # the package acts on your fake
MeanReversion().on_bar(fake, {"open": 2.0, "close": 1.0})
assert seen