4
4
5
5
6
6
@pytest .mark .parametrize ("create_package" , [get_simple_package_path (), get_verify_status_package_path (),
7
- get_checker_package_path ()], indirect = True )
7
+ get_checker_package_path (), get_library_package_path () ], indirect = True )
8
8
def test_simple (create_package , time_tool ):
9
9
"""
10
10
Test a simple run.
@@ -20,7 +20,7 @@ def test_simple(create_package, time_tool):
20
20
21
21
22
22
@pytest .mark .parametrize ("create_package" , [get_simple_package_path (), get_verify_status_package_path (),
23
- get_checker_package_path ()], indirect = True )
23
+ get_checker_package_path (), get_library_package_path () ], indirect = True )
24
24
def test_no_expected_scores (capsys , create_package , time_tool ):
25
25
"""
26
26
Test with no sinol_expected_scores in config.yml.
@@ -31,9 +31,11 @@ def test_no_expected_scores(capsys, create_package, time_tool):
31
31
create_ins_outs (package_path )
32
32
33
33
config_path = os .path .join (package_path , "config.yml" )
34
- config = yaml .load (open (config_path , "r" ), Loader = yaml .SafeLoader )
34
+ with open (config_path , "r" ) as config_file :
35
+ config = yaml .load (config_file , Loader = yaml .SafeLoader )
35
36
del config ["sinol_expected_scores" ]
36
- open (config_path , "w" ).write (yaml .dump (config ))
37
+ with open (config_path , "w" ) as config_file :
38
+ config_file .write (yaml .dump (config ))
37
39
38
40
parser = configure_parsers ()
39
41
args = parser .parse_args (["run" , "--time-tool" , time_tool ])
@@ -51,7 +53,7 @@ def test_no_expected_scores(capsys, create_package, time_tool):
51
53
52
54
53
55
@pytest .mark .parametrize ("create_package" , [get_simple_package_path (), get_verify_status_package_path (),
54
- get_checker_package_path ()], indirect = True )
56
+ get_checker_package_path (), get_library_package_path () ], indirect = True )
55
57
def test_apply_suggestions (create_package , time_tool ):
56
58
"""
57
59
Test with no sinol_expected_scores in config.yml.
@@ -62,17 +64,20 @@ def test_apply_suggestions(create_package, time_tool):
62
64
create_ins_outs (package_path )
63
65
64
66
config_path = os .path .join (package_path , "config.yml" )
65
- config = yaml .load (open (config_path , "r" ), Loader = yaml .SafeLoader )
67
+ with open (config_path , "r" ) as config_file :
68
+ config = yaml .load (config_file , Loader = yaml .SafeLoader )
66
69
expected_scores = config ["sinol_expected_scores" ]
67
70
del config ["sinol_expected_scores" ]
68
- open (config_path , "w" ).write (yaml .dump (config ))
71
+ with open (config_path , "w" ) as config_file :
72
+ config_file .write (yaml .dump (config ))
69
73
70
74
parser = configure_parsers ()
71
75
args = parser .parse_args (["run" , "--apply-suggestions" , "--time-tool" , time_tool ])
72
76
command = Command ()
73
77
command .run (args )
74
78
75
- config = yaml .load (open (config_path , "r" ), Loader = yaml .SafeLoader )
79
+ with open (config_path , "r" ) as config_file :
80
+ config = yaml .load (config_file , Loader = yaml .SafeLoader )
76
81
assert config ["sinol_expected_scores" ] == expected_scores
77
82
78
83
@@ -86,10 +91,12 @@ def test_incorrect_expected_scores(capsys, create_package, time_tool):
86
91
create_ins_outs (package_path )
87
92
88
93
config_path = os .path .join (package_path , "config.yml" )
89
- config = yaml .load (open (config_path , "r" ), Loader = yaml .SafeLoader )
94
+ with open (config_path , "r" ) as config_file :
95
+ config = yaml .load (config_file , Loader = yaml .SafeLoader )
90
96
config ["sinol_expected_scores" ]["abc.cpp" ]["expected" ][1 ] = "WA"
91
97
config ["sinol_expected_scores" ]["abc.cpp" ]["points" ] = 75
92
- open (config_path , "w" ).write (yaml .dump (config ))
98
+ with open (config_path , "w" ) as config_file :
99
+ config_file .write (yaml .dump (config ))
93
100
94
101
parser = configure_parsers ()
95
102
args = parser .parse_args (["run" , "--time-tool" , time_tool ])
@@ -105,7 +112,8 @@ def test_incorrect_expected_scores(capsys, create_package, time_tool):
105
112
assert "Solution abc.cpp passed group 1 with status OK while it should pass with status WA." in out
106
113
107
114
108
- @pytest .mark .parametrize ("create_package" , [get_simple_package_path (), get_checker_package_path ()], indirect = True )
115
+ @pytest .mark .parametrize ("create_package" , [get_simple_package_path (), get_checker_package_path (),
116
+ get_library_package_path ()], indirect = True )
109
117
def test_flag_tests (create_package , time_tool ):
110
118
"""
111
119
Test flag --tests.
@@ -178,9 +186,11 @@ def test_no_scores(capsys, create_package, time_tool):
178
186
create_ins_outs (package_path )
179
187
180
188
config_path = os .path .join (package_path , "config.yml" )
181
- config = yaml .load (open (config_path , "r" ), Loader = yaml .SafeLoader )
189
+ with open (config_path , "r" ) as config_file :
190
+ config = yaml .load (config_file , Loader = yaml .SafeLoader )
182
191
del config ["scores" ]
183
- open (config_path , "w" ).write (yaml .dump (config ))
192
+ with open (config_path , "w" ) as config_file :
193
+ config_file .write (yaml .dump (config ))
184
194
185
195
parser = configure_parsers ()
186
196
args = parser .parse_args (["run" , "--time-tool" , time_tool ])
0 commit comments