Skip to content

Commit e7df7d5

Browse files
Michael Brewerheitorlessa
Michael Brewer
andauthored
tests: use capsys
Co-authored-by: Heitor Lessa <[email protected]>
1 parent efa025f commit e7df7d5

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

tests/functional/event_handler/test_api_gateway.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -655,16 +655,14 @@ def foo():
655655
assert result["body"] == json.dumps(response, indent=4)
656656

657657

658-
def test_debug_print_event(monkeypatch):
658+
def test_debug_print_event(capsys):
659659
# GIVE debug is True
660660
app = ApiGatewayResolver(debug=True)
661-
mocked_print = MagicMock()
662-
monkeypatch.setattr(builtins, "print", mocked_print)
663661

664662
# WHEN calling resolve
665663
event = {"path": "/foo", "httpMethod": "GET"}
666664
app(event, None)
667665

668666
# THEN print the event
669-
# NOTE: other calls might have happened outside of this mock
670-
mocked_print.assert_any_call(json.dumps(event, indent=4))
667+
out, err = capsys.readouterr()
668+
assert json.loads(out) == event

0 commit comments

Comments
 (0)