File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ and this project adheres to
2525
2626### Fixed
2727
28+ - Fix leaked file handles in tests using context managers ([ b66a6f5] , [ #25 ] )
2829- Fix typo in test name: ` test_l9events_form_ip4scout ` ->
2930 ` test_l9events_from_ip4scout ` ([ 0d8736e] , [ #27 ] )
3031
@@ -150,6 +151,7 @@ and this project adheres to
150151
151152<!-- Commit links -->
152153
154+ [ b66a6f5 ] : https://github.com/LeakIX/l9format-python/commit/b66a6f5
153155[ 3547e22 ] : https://github.com/LeakIX/l9format-python/commit/3547e22
154156[ 1ca6e4d ] : https://github.com/LeakIX/l9format-python/commit/1ca6e4d
155157[ 0d8736e ] : https://github.com/LeakIX/l9format-python/commit/0d8736e
@@ -218,4 +220,5 @@ and this project adheres to
218220[ #22 ] : https://github.com/LeakIX/l9format-python/issues/22
219221[ #27 ] : https://github.com/LeakIX/l9format-python/issues/27
220222[ #33 ] : https://github.com/LeakIX/l9format-python/issues/33
223+ [ #25 ] : https://github.com/LeakIX/l9format-python/issues/25
221224[ #35 ] : https://github.com/LeakIX/l9format-python/issues/35
Original file line number Diff line number Diff line change 11import json
2- import os
32from pathlib import Path
43
54from l9format import L9Event
65
7- TESTS_DIR = Path (os . path . dirname ( __file__ ))
6+ TESTS_DIR = Path (__file__ ). parent
87
98IP4SCOUT_FILES = [
109 f
1514
1615def test_l9event_json_from_reference_repository ():
1716 path = TESTS_DIR / "l9event.json"
18- c = json .load (open (str (path ), "r" ))
17+ with open (path ) as f :
18+ c = json .load (f )
1919 L9Event .from_dict (c )
2020
2121
2222def test_l9events_from_ip4scout ():
2323 for path in IP4SCOUT_FILES :
24- c = json .load (open (str (path ), "r" ))
24+ with open (path ) as f :
25+ c = json .load (f )
2526 L9Event .from_dict (c )
2627
2728
@@ -33,7 +34,8 @@ def test_iso8601_nanosecond_parsing():
3334 correctly in Python 3.11+.
3435 """
3536 path = TESTS_DIR / "l9event.json"
36- c = json .load (open (str (path ), "r" ))
37+ with open (path ) as f :
38+ c = json .load (f )
3739 # Use a timestamp with nanosecond precision (9 decimal places)
3840 c ["time" ] = "2023-10-05T23:30:36.823867784Z"
3941 event = L9Event .from_dict (c )
You can’t perform that action at this time.
0 commit comments