def test_cry_fh(monkeypatch, capfd): import manhole monkeypatch.setattr(manhole, '_VERBOSE', True) class output: data = [] write = data.append monkeypatch.setattr(manhole, '_VERBOSE_DESTINATION', output) manhole._cry("whatever") assert len(output.data) == 1 assert "]: whatever" in output.data[0]
def test_cry_fd(monkeypatch, capfd): import manhole monkeypatch.setattr(manhole, '_VERBOSE', True) monkeypatch.setattr(manhole, '_VERBOSE_DESTINATION', 2) manhole._cry("whatever") assert "]: whatever" in capfd.readouterr()[1]