Corey Morris commited on
Commit
3ec98e7
1 Parent(s): 5603e9f

Added a first regression test attempt. It currently fails and values are hardcoded

Browse files
Files changed (1) hide show
  1. test_regression.py +44 -0
test_regression.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+ import pandas as pd
3
+ import unittest
4
+ from result_data_processor import ResultDataProcessor
5
+ import os
6
+
7
+ class TestRegression(unittest.TestCase):
8
+ def test_data_output_is_the_same(self):
9
+
10
+ # # Run code and get output
11
+ # df = ResultDataProcessor().data
12
+
13
+ # # Save output to CSV
14
+ # commit = '5603e9f51b643dbbb3da62943d5f26c48e11ae9b'
15
+ # outfile = f'output_{commit}.csv'
16
+ # df.to_csv(outfile)
17
+
18
+ # # Checkout previous commit
19
+ # prev_commit = '02b17021c8c2759ae08d23578b11bdb493941479'
20
+ # checkout_command = f'git checkout {prev_commit}'
21
+ # os.system(checkout_command)
22
+
23
+ # # Rerun and save output
24
+ # df = ResultDataProcessor().data
25
+ # prev_outfile = f'output_{prev_commit}.csv'
26
+ # prev_df.to_csv(prev_outfile)
27
+
28
+ # # Diff outputs
29
+ # import filecmp
30
+ # assert filecmp.cmp(outfile, prev_outfile)
31
+
32
+ df_current = ResultDataProcessor().data
33
+
34
+ # Load the reference output file (generated manually from a previous commit)
35
+ commit = '5b83d0bbaf92089fd7713e9e8edaa14c821b0dc7'
36
+ reference_file = f'output_{commit}.csv'
37
+ df_reference = pd.read_csv(reference_file)
38
+
39
+ # Compare DataFrames, allowing for some tolerance in floating-point comparisons
40
+ pd.testing.assert_frame_equal(df_current, df_reference, check_dtype=False, atol=1e-5)
41
+
42
+
43
+ if __name__ == '__main__':
44
+ unittest.main()