1+ import argparse
12import os
23
34import readsql .__main__ as rsql
@@ -19,7 +20,9 @@ def test_read_file():
1920def test_read_python_file_wrap ():
2021 @timing
2122 def test_read_python_file ():
22- return rsql .read_python_file (file_name = DIR + '/sql_in_python_example.py' , inplace = False )
23+ return rsql .read_python_file (
24+ file_name = DIR + '/sql_in_python_example.py' , inplace = False
25+ )
2326
2427 example = test_read_python_file ()
2528 with open (DIR + '/sql_in_python_example_correct.py' , 'r' ) as inp :
@@ -29,7 +32,11 @@ def test_read_python_file():
2932def test_read_python_file_variable_wrap ():
3033 @timing
3134 def test_read_python_file (variable ):
32- return rsql .read_python_file (file_name = DIR + '/sql_in_python_variable_example.py' , variables = variable , inplace = False )
35+ return rsql .read_python_file (
36+ file_name = DIR + '/sql_in_python_variable_example.py' ,
37+ variables = variable ,
38+ inplace = False ,
39+ )
3340
3441 example = test_read_python_file (variable = ['sql' ])
3542 with open (DIR + '/sql_in_python_variable_example_correct.py' , 'r' ) as inp :
@@ -39,8 +46,39 @@ def test_read_python_file(variable):
3946def test_read_python_file_variables_wrap ():
4047 @timing
4148 def test_read_python_file (variable ):
42- return rsql .read_python_file (file_name = DIR + '/sql_in_python_variables_example.py' , variables = variable , inplace = False )
49+ return rsql .read_python_file (
50+ file_name = DIR + '/sql_in_python_variables_example.py' ,
51+ variables = variable ,
52+ inplace = False ,
53+ )
4354
4455 example = test_read_python_file (variable = ['sql' , 'query_template' , 'query' ])
4556 with open (DIR + '/sql_in_python_variables_example_correct.py' , 'r' ) as inp :
4657 assert inp .read () == example
58+
59+
60+ def test_read_python_multifile_wrap ():
61+ args = argparse .Namespace (
62+ nothing = True ,
63+ path = [
64+ DIR + '/sql_in_python_multifile1_example.py' ,
65+ DIR + '/sql_in_python_multifile2_example.py' ,
66+ ],
67+ python_var = ['query' ],
68+ string = False ,
69+ )
70+
71+ @timing
72+ def test_read_python_multifile ():
73+ return rsql .command_line_file (args )
74+
75+ example = test_read_python_multifile ()
76+ corrects = [
77+ DIR + '/sql_in_python_multifile1_example_correct.py' ,
78+ DIR + '/sql_in_python_multifile2_example_correct.py' ,
79+ ]
80+ aggregate = []
81+ for file in corrects :
82+ with open (file , 'r' ) as inp :
83+ aggregate .append (inp .read ())
84+ assert str (aggregate ) == str (example )
0 commit comments