Initial Commit

This commit is contained in:
2024-12-02 20:08:23 +01:00
commit e340d6b99e
14 changed files with 1340 additions and 0 deletions

29
test_compare_output.py Executable file
View File

@@ -0,0 +1,29 @@
import unittest
import subprocess
class TestOutputComparison(unittest.TestCase):
def test_compare_output(self):
# Define the Python script to run and the expected output file
script_to_run = 'interpolation_error.py' # Replace with your script's name
expected_file = 'reference_output.txt'
# Run the script and capture the output
result = subprocess.run(['python3', script_to_run], capture_output=True, text=True)
output_lines = result.stdout.splitlines()
# Open and read the expected output file
with open(expected_file, 'r') as expected:
expected_lines = expected.read().splitlines()
# Ensure the number of lines is the same
self.assertEqual(len(output_lines), len(expected_lines),
"The number of lines in the output does not match the expected output.")
# Compare each line
for i, (output_line, expected_line) in enumerate(zip(output_lines, expected_lines)):
self.assertEqual(output_line.strip(), expected_line.strip(),
f"Line {i+1} does not match:\nOutput: {output_line}\nExpected: {expected_line}")
if __name__ == '__main__':
unittest.main()