From 248a9c475aefe0637d977de095c324cb846012ec Mon Sep 17 00:00:00 2001 From: admeeer Date: Tue, 10 Oct 2023 16:26:40 -0700 Subject: [PATCH] Adds script and test_script, sets .yml testing location to tests/ --- .github/workflows/automation.yml | 2 +- script.py | 2 ++ tests/test_script.py | 11 +++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 script.py create mode 100644 tests/test_script.py diff --git a/.github/workflows/automation.yml b/.github/workflows/automation.yml index cdbae39..caafdbb 100644 --- a/.github/workflows/automation.yml +++ b/.github/workflows/automation.yml @@ -25,4 +25,4 @@ jobs: - name: test run: | - pytest + pytest tests/ diff --git a/script.py b/script.py new file mode 100644 index 0000000..a38d7c0 --- /dev/null +++ b/script.py @@ -0,0 +1,2 @@ +# script.py +print("Hello, World!") \ No newline at end of file diff --git a/tests/test_script.py b/tests/test_script.py new file mode 100644 index 0000000..cd7e600 --- /dev/null +++ b/tests/test_script.py @@ -0,0 +1,11 @@ +# test_script.py +import subprocess + +def test_hello_world_output(capfd): + subprocess.run(['python', './script.py']) + + # Capture the output + captured = capfd.readouterr() + + # Assert the output is correct + assert captured.out == "Hello, World!\n"