@@ -231,7 +231,9 @@ def test_locker_properly_loads_extras(locker: Locker):
231
231
content-hash = "c3d07fca33fba542ef2b2a4d75bf5b48d892d21a830e2ad9c952ba5123a52f77"
232
232
""" # noqa: E800
233
233
234
- locker .lock .write (tomlkit .parse (content ))
234
+ data = tomlkit .parse (content )
235
+ with open (locker .lock , "w" , encoding = "utf-8" ) as f :
236
+ f .write (data .as_string ())
235
237
236
238
packages = locker .locked_repository ().packages
237
239
@@ -294,7 +296,9 @@ def test_locker_properly_loads_nested_extras(locker: Locker):
294
296
content-hash = "123456789"
295
297
""" # noqa: E800
296
298
297
- locker .lock .write (tomlkit .parse (content ))
299
+ data = tomlkit .parse (content )
300
+ with open (locker .lock , "w" , encoding = "utf-8" ) as f :
301
+ f .write (data .as_string ())
298
302
299
303
repository = locker .locked_repository ()
300
304
assert len (repository .packages ) == 3
@@ -359,7 +363,9 @@ def test_locker_properly_loads_extras_legacy(locker: Locker):
359
363
content-hash = "123456789"
360
364
""" # noqa: E800
361
365
362
- locker .lock .write (tomlkit .parse (content ))
366
+ data = tomlkit .parse (content )
367
+ with open (locker .lock , "w" , encoding = "utf-8" ) as f :
368
+ f .write (data .as_string ())
363
369
364
370
repository = locker .locked_repository ()
365
371
assert len (repository .packages ) == 2
@@ -399,7 +405,9 @@ def test_locker_properly_loads_subdir(locker: Locker) -> None:
399
405
python-versions = "*"
400
406
content-hash = "115cf985d932e9bf5f540555bbdd75decbb62cac81e399375fc19f6277f8c1d8"
401
407
"""
402
- locker .lock .write (tomlkit .parse (content ))
408
+ data = tomlkit .parse (content )
409
+ with open (locker .lock , "w" , encoding = "utf-8" ) as f :
410
+ f .write (data .as_string ())
403
411
404
412
repository = locker .locked_repository ()
405
413
assert len (repository .packages ) == 1
@@ -495,7 +503,9 @@ def test_locker_properly_assigns_metadata_files(locker: Locker) -> None:
495
503
{file = "demo-1.0-py3-none-any.whl", hash = "sha256"},
496
504
]
497
505
"""
498
- locker .lock .write (tomlkit .parse (content ))
506
+ data = tomlkit .parse (content )
507
+ with open (locker .lock , "w" , encoding = "utf-8" ) as f :
508
+ f .write (data .as_string ())
499
509
500
510
repository = locker .locked_repository ()
501
511
assert len (repository .packages ) == 5
@@ -687,7 +697,9 @@ def test_locker_should_emit_warnings_if_lock_version_is_newer_but_allowed(
687
697
"""
688
698
caplog .set_level (logging .WARNING , logger = "poetry.packages.locker" )
689
699
690
- locker .lock .write (tomlkit .parse (content ))
700
+ data = tomlkit .parse (content )
701
+ with open (locker .lock , "w" , encoding = "utf-8" ) as f :
702
+ f .write (data .as_string ())
691
703
692
704
_ = locker .lock_data
693
705
@@ -717,7 +729,9 @@ def test_locker_should_raise_an_error_if_lock_version_is_newer_and_not_allowed(
717
729
""" # noqa: E800
718
730
caplog .set_level (logging .WARNING , logger = "poetry.packages.locker" )
719
731
720
- locker .lock .write (tomlkit .parse (content ))
732
+ data = tomlkit .parse (content )
733
+ with open (locker .lock , "w" , encoding = "utf-8" ) as f :
734
+ f .write (data .as_string ())
721
735
722
736
with pytest .raises (RuntimeError , match = "^The lock file is not compatible" ):
723
737
_ = locker .lock_data
@@ -775,7 +789,9 @@ def test_locker_should_neither_emit_warnings_nor_raise_error_for_lower_compatibl
775
789
"""
776
790
caplog .set_level (logging .WARNING , logger = "poetry.packages.locker" )
777
791
778
- locker .lock .write (tomlkit .parse (content ))
792
+ data = tomlkit .parse (content )
793
+ with open (locker .lock , "w" , encoding = "utf-8" ) as f :
794
+ f .write (data .as_string ())
779
795
780
796
_ = locker .lock_data
781
797
@@ -970,7 +986,10 @@ def test_locked_repository_uses_root_dir_of_package(
970
986
content-hash = "115cf985d932e9bf5f540555bbdd75decbb62cac81e399375fc19f6277f8c1d8"
971
987
""" # noqa: E800
972
988
973
- locker .lock .write (tomlkit .parse (content ))
989
+ data = tomlkit .parse (content )
990
+ with open (locker .lock , "w" , encoding = "utf-8" ) as f :
991
+ f .write (data .as_string ())
992
+
974
993
create_dependency_patch = mocker .patch (
975
994
"poetry.factory.Factory.create_dependency" , autospec = True
976
995
)
@@ -983,7 +1002,7 @@ def test_locked_repository_uses_root_dir_of_package(
983
1002
root_dir = call_kwargs ["root_dir" ]
984
1003
assert root_dir .match ("*/lib/libA" )
985
1004
# relative_to raises an exception if not relative - is_relative_to comes in py3.9
986
- assert root_dir .relative_to (locker .lock .path . parent .resolve ()) is not None
1005
+ assert root_dir .relative_to (locker .lock .parent .resolve ()) is not None
987
1006
988
1007
989
1008
@pytest .mark .parametrize (
@@ -1017,7 +1036,7 @@ def test_content_hash_with_legacy_is_compatible(
1017
1036
relevant_content [key ] = local_config .get (key )
1018
1037
1019
1038
locker = locker .__class__ (
1020
- lock = locker .lock . path ,
1039
+ lock = locker .lock ,
1021
1040
local_config = local_config ,
1022
1041
)
1023
1042
0 commit comments