[python] Prevent "ResourceWarning: unclosed file <_io.TextIOWrapper

This commit is contained in:
Markus Blatt 2023-01-13 17:06:43 +01:00
parent dd0ac8a669
commit b007ef345c

View File

@ -83,7 +83,8 @@ class TestTimeVector(unittest.TestCase):
datetime.datetime(1998, 8, 1)])
def test_str(self):
tv = TimeVector(datetime.date(1997, 11, 6), base_string = open(test_path("data/schedule/part1.sch")).read())
with open(test_path("data/schedule/part1.sch")) as f:
tv = TimeVector(datetime.date(1997, 11, 6), base_string = f.read())
tv.load(test_path("data/schedule/part3.sch"))
tv.load(test_path("data/schedule/part2.sch"))