Skip to content
Snippets Groups Projects
Commit ac7d45a0 authored by Hans Fangohr's avatar Hans Fangohr
Browse files

minor modification

- sys.__stdout__ is the value stdout had at the beginning of the Python program.
- instead, let's reconnect to the stdout stream we used immediately before we
  redirected into the StringIO object. This should be (mildly) more robust.
parent 9d62ea27
No related branches found
No related tags found
1 merge request!21test that the counter works
Pipeline #368922 passed
This commit is part of merge request !21. Comments created here will be created in the context of that merge request.
......@@ -102,10 +102,11 @@ def test_run_method(tmp_path):
# check that ##-08 is printed when run(["echo", "Good Bye, world!"]) is run
# the 8 in ##-08 is present because
# this is the 8th run of the `run` function
stdout_original = sys.stdout # preserve current stdout stream
captured_output = StringIO() # create an in-memory file-like object.
sys.stdout = captured_output # redirect stdout to the file
run(["echo", "Good Bye, world!"])
sys.stdout = sys.__stdout__ # restores the original stdout
sys.stdout = stdout_original # restores the original stdout
assert "##-08" in captured_output.getvalue()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment