--- /dev/null
+import io, sys, os, time
+from tester import run
+
+
+class Capturing(list):
+ def __enter__(self):
+ self._stdout = sys.stdout
+ sys.stdout = self._stringio = io.StringIO()
+ return self
+
+ def __exit__(self, *args):
+ self.extend(self._stringio.getvalue().splitlines())
+ del self._stringio # free up some memory
+ sys.stdout = self._stdout
+
+
+PATH = "2012/"
+PROBLEM = "S1"
+
+test_input_path = os.path.join(PATH, f"windows_data/senior/{PROBLEM}/")
+
+test_inputs = []
+test_outputs = []
+for root, dirs, files in os.walk(test_input_path):
+ for i, file in enumerate(files):
+ with open(os.path.join(root, file), "r") as f:
+ if i % 2 == 0:
+ test_inputs.append(f.read())
+ else:
+ test_outputs.append(f.read())
+
+total = min(len(test_inputs), len(test_outputs))
+correct = 0
+
+for test_input, test_output in zip(test_inputs, test_outputs):
+ with Capturing() as output:
+ start = time.perf_counter()
+ run(PATH, PROBLEM, test_input)
+ end = time.perf_counter()
+
+ if "\n".join(output) + "\n" == test_output:
+ print(f"Test Passed. {round(end - start, 3)}s")
+ correct += 1
+ else:
+ print(f"Test Failed. {round(end - start, 3)}s")
+ print(f"{test_input = }")
+ print(f"{test_output = }")
+
+print("--------------------------------")
+print(f"Tests passed: {correct}/{total}")
\ No newline at end of file
--- /dev/null
+import sys, io, importlib, os
+
+
+def run(PATH, PROBLEM, test_input):
+ sys.stdin = io.StringIO(test_input)
+ exec(open(os.path.join(PATH, PROBLEM + ".py")).read())
-test = {1:0,2:1,3:-1}
-print(max(test.values()))
+import io, sys, os
+import importlib
+
+class Capturing(list):
+ def __enter__(self):
+ self._stdout = sys.stdout
+ sys.stdout = self._stringio = io.StringIO()
+ return self
+ def __exit__(self, *args):
+ self.extend(self._stringio.getvalue().splitlines())
+ del self._stringio # free up some memory
+ sys.stdout = self._stdout
+
+
+filename = "test2.py"
+# file =
+
+
+for i in range(3):
+ with Capturing() as output:
+ x = os.system(filename)
+
+ print("\n".join(output), type(output))
+ print("a")
+
+
+# test = {1:0,2:1,3:-1}
+# print(max(test.values()))
# test = {1,2,3}