Jacob ChapmanOct. 17, 2024, 3:41 a.m. re: pytest REPL I think the solution here is to write REPL-friendly functions and keep the pytest part to only data assertions. Of course, you can launch the ipython debugger from pytest like this: pytest --pdbcls=IPython.terminal.debugger:TerminalPdb --pdb (and then type interact to go into multi-line REPL mode) If you have many assertions you can save the expected output to external files; pytest-regressions provides a nice interface for this: https://github.com/ESSS/pytest-regressions @pytest.fixture def assert_unchanged(data_regression, request): def assert_unchanged(captured, basename=None): data_regression.check(captured, basename=basename if basename else request.node.name.replace("-", " ")) return assert_unchanged And here is an example of its use: @pytest.mark.parametrize("p", [["1970-01-01 00:00:01"], ["--from-unix", "1"]]) @pytest.mark.parametrize("fz", [["-fz", "America/New_York"], ["-fz", "America/Chicago"]]) @pytest.mark.parametrize("tz", [["-tz", "America/New_York"], ["-tz", "America/Chicago"]]) @pytest.mark.parametrize("s", [[], ["-d"], ["-t"]]) @pytest.mark.parametrize("f", [[], ["-TZ"]]) def test_lb_timestamps_tz(assert_unchanged, p, fz, tz, s, f, capsys): lb(["timestamps", *p, *fz, *tz, *s, *f]) captured = capsys.readouterr().out.strip() assert_unchanged(captured) Reply Report Reply and Subscribe
re: pytest REPL
I think the solution here is to write REPL-friendly functions and keep the pytest part to only data assertions.
Of course, you can launch the ipython debugger from pytest like this:
(and then type
interact
to go into multi-line REPL mode)If you have many assertions you can save the expected output to external files; pytest-regressions provides a nice interface for this:
https://github.com/ESSS/pytest-regressions
And here is an example of its use: