@@ -538,8 +538,8 @@ def test_provides_extra(self, tmpdir_cwd, env):
538
538
env = environ ,
539
539
)
540
540
egg_info_dir = os .path .join ('.' , 'foo.egg-info' )
541
- with open (os .path .join (egg_info_dir , 'PKG-INFO' ), encoding = "utf-8" ) as pkginfo_file :
542
- pkg_info_lines = pkginfo_file .read ().split ('\n ' )
541
+ with open (os .path .join (egg_info_dir , 'PKG-INFO' ), encoding = "utf-8" ) as fp :
542
+ pkg_info_lines = fp .read ().split ('\n ' )
543
543
assert 'Provides-Extra: foobar' in pkg_info_lines
544
544
assert 'Metadata-Version: 2.1' in pkg_info_lines
545
545
@@ -557,8 +557,8 @@ def test_doesnt_provides_extra(self, tmpdir_cwd, env):
557
557
env = environ ,
558
558
)
559
559
egg_info_dir = os .path .join ('.' , 'foo.egg-info' )
560
- with open (os .path .join (egg_info_dir , 'PKG-INFO' ), encoding = "utf-8" ) as pkginfo_file :
561
- pkg_info_text = pkginfo_file .read ()
560
+ with open (os .path .join (egg_info_dir , 'PKG-INFO' ), encoding = "utf-8" ) as fp :
561
+ pkg_info_text = fp .read ()
562
562
assert 'Provides-Extra:' not in pkg_info_text
563
563
564
564
@pytest .mark .parametrize (
@@ -636,8 +636,7 @@ def test_setup_cfg_license_file(self, tmpdir_cwd, env, files, license_in_sources
636
636
)
637
637
egg_info_dir = os .path .join ('.' , 'foo.egg-info' )
638
638
639
- with open (os .path .join (egg_info_dir , 'SOURCES.txt' ), encoding = "utf-8" ) as sources_file :
640
- sources_text = sources_file .read ()
639
+ sources_text = Path (egg_info_dir , "SOURCES.txt" ).read_text (encoding = "utf-8" )
641
640
642
641
if license_in_sources :
643
642
assert 'LICENSE' in sources_text
@@ -849,8 +848,8 @@ def test_setup_cfg_license_files(
849
848
)
850
849
egg_info_dir = os .path .join ('.' , 'foo.egg-info' )
851
850
852
- with open ( os . path . join ( egg_info_dir , ' SOURCES.txt' ), encoding = "utf-8" ) as sources_file :
853
- sources_lines = list ( line .strip () for line in sources_file )
851
+ sources_text = Path ( egg_info_dir , " SOURCES.txt" ). read_text ( encoding = "utf-8" )
852
+ sources_lines = [ line .strip () for line in sources_text . splitlines ()]
854
853
855
854
for lf in incl_licenses :
856
855
assert sources_lines .count (lf ) == 1
@@ -1033,8 +1032,8 @@ def test_setup_cfg_license_file_license_files(
1033
1032
)
1034
1033
egg_info_dir = os .path .join ('.' , 'foo.egg-info' )
1035
1034
1036
- with open ( os . path . join ( egg_info_dir , ' SOURCES.txt' ), encoding = "utf-8" ) as sources_file :
1037
- sources_lines = list ( line .strip () for line in sources_file )
1035
+ sources_text = Path ( egg_info_dir , " SOURCES.txt" ). read_text ( encoding = "utf-8" )
1036
+ sources_lines = [ line .strip () for line in sources_text . splitlines ()]
1038
1037
1039
1038
for lf in incl_licenses :
1040
1039
assert sources_lines .count (lf ) == 1
@@ -1065,8 +1064,8 @@ def test_license_file_attr_pkg_info(self, tmpdir_cwd, env):
1065
1064
pypath = os .pathsep .join ([env .paths ['lib' ], str (tmpdir_cwd )]),
1066
1065
)
1067
1066
egg_info_dir = os .path .join ('.' , 'foo.egg-info' )
1068
- with open (os .path .join (egg_info_dir , 'PKG-INFO' ), encoding = "utf-8" ) as pkginfo_file :
1069
- pkg_info_lines = pkginfo_file .read ().split ('\n ' )
1067
+ with open (os .path .join (egg_info_dir , 'PKG-INFO' ), encoding = "utf-8" ) as fp :
1068
+ pkg_info_lines = fp .read ().split ('\n ' )
1070
1069
license_file_lines = [
1071
1070
line for line in pkg_info_lines if line .startswith ('License-File:' )
1072
1071
]
@@ -1086,8 +1085,8 @@ def test_metadata_version(self, tmpdir_cwd, env):
1086
1085
data_stream = 1 ,
1087
1086
)
1088
1087
egg_info_dir = os .path .join ('.' , 'foo.egg-info' )
1089
- with open (os .path .join (egg_info_dir , 'PKG-INFO' ), encoding = "utf-8" ) as pkginfo_file :
1090
- pkg_info_lines = pkginfo_file .read ().split ('\n ' )
1088
+ with open (os .path .join (egg_info_dir , 'PKG-INFO' ), encoding = "utf-8" ) as fp :
1089
+ pkg_info_lines = fp .read ().split ('\n ' )
1091
1090
# Update metadata version if changed
1092
1091
assert self ._extract_mv_version (pkg_info_lines ) == (2 , 1 )
1093
1092
@@ -1112,8 +1111,8 @@ def test_long_description_content_type(self, tmpdir_cwd, env):
1112
1111
env = environ ,
1113
1112
)
1114
1113
egg_info_dir = os .path .join ('.' , 'foo.egg-info' )
1115
- with open (os .path .join (egg_info_dir , 'PKG-INFO' ), encoding = "utf-8" ) as pkginfo_file :
1116
- pkg_info_lines = pkginfo_file .read ().split ('\n ' )
1114
+ with open (os .path .join (egg_info_dir , 'PKG-INFO' ), encoding = "utf-8" ) as fp :
1115
+ pkg_info_lines = fp .read ().split ('\n ' )
1117
1116
expected_line = 'Description-Content-Type: text/markdown'
1118
1117
assert expected_line in pkg_info_lines
1119
1118
assert 'Metadata-Version: 2.1' in pkg_info_lines
@@ -1133,8 +1132,8 @@ def test_long_description(self, tmpdir_cwd, env):
1133
1132
data_stream = 1 ,
1134
1133
)
1135
1134
egg_info_dir = os .path .join ('.' , 'foo.egg-info' )
1136
- with open (os .path .join (egg_info_dir , 'PKG-INFO' ), encoding = "utf-8" ) as pkginfo_file :
1137
- pkg_info_lines = pkginfo_file .read ().split ('\n ' )
1135
+ with open (os .path .join (egg_info_dir , 'PKG-INFO' ), encoding = "utf-8" ) as fp :
1136
+ pkg_info_lines = fp .read ().split ('\n ' )
1138
1137
assert 'Metadata-Version: 2.1' in pkg_info_lines
1139
1138
assert '' == pkg_info_lines [- 1 ] # last line should be empty
1140
1139
long_desc_lines = pkg_info_lines [pkg_info_lines .index ('' ) :]
@@ -1165,8 +1164,8 @@ def test_project_urls(self, tmpdir_cwd, env):
1165
1164
env = environ ,
1166
1165
)
1167
1166
egg_info_dir = os .path .join ('.' , 'foo.egg-info' )
1168
- with open (os .path .join (egg_info_dir , 'PKG-INFO' ), encoding = "utf-8" ) as pkginfo_file :
1169
- pkg_info_lines = pkginfo_file .read ().split ('\n ' )
1167
+ with open (os .path .join (egg_info_dir , 'PKG-INFO' ), encoding = "utf-8" ) as fp :
1168
+ pkg_info_lines = fp .read ().split ('\n ' )
1170
1169
expected_line = 'Project-URL: Link One, https://example.com/one/'
1171
1170
assert expected_line in pkg_info_lines
1172
1171
expected_line = 'Project-URL: Link Two, https://example.com/two/'
@@ -1182,8 +1181,8 @@ def test_license(self, tmpdir_cwd, env):
1182
1181
data_stream = 1 ,
1183
1182
)
1184
1183
egg_info_dir = os .path .join ('.' , 'foo.egg-info' )
1185
- with open (os .path .join (egg_info_dir , 'PKG-INFO' ), encoding = "utf-8" ) as pkginfo_file :
1186
- pkg_info_lines = pkginfo_file .read ().split ('\n ' )
1184
+ with open (os .path .join (egg_info_dir , 'PKG-INFO' ), encoding = "utf-8" ) as fp :
1185
+ pkg_info_lines = fp .read ().split ('\n ' )
1187
1186
assert 'License: MIT' in pkg_info_lines
1188
1187
1189
1188
def test_license_escape (self , tmpdir_cwd , env ):
@@ -1197,8 +1196,8 @@ def test_license_escape(self, tmpdir_cwd, env):
1197
1196
data_stream = 1 ,
1198
1197
)
1199
1198
egg_info_dir = os .path .join ('.' , 'foo.egg-info' )
1200
- with open (os .path .join (egg_info_dir , 'PKG-INFO' ), encoding = "utf-8" ) as pkginfo_file :
1201
- pkg_info_lines = pkginfo_file .read ().split ('\n ' )
1199
+ with open (os .path .join (egg_info_dir , 'PKG-INFO' ), encoding = "utf-8" ) as fp :
1200
+ pkg_info_lines = fp .read ().split ('\n ' )
1202
1201
1203
1202
assert 'License: This is a long license text ' in pkg_info_lines
1204
1203
assert ' over multiple lines' in pkg_info_lines
@@ -1216,8 +1215,8 @@ def test_python_requires_egg_info(self, tmpdir_cwd, env):
1216
1215
env = environ ,
1217
1216
)
1218
1217
egg_info_dir = os .path .join ('.' , 'foo.egg-info' )
1219
- with open (os .path .join (egg_info_dir , 'PKG-INFO' ), encoding = "utf-8" ) as pkginfo_file :
1220
- pkg_info_lines = pkginfo_file .read ().split ('\n ' )
1218
+ with open (os .path .join (egg_info_dir , 'PKG-INFO' ), encoding = "utf-8" ) as fp :
1219
+ pkg_info_lines = fp .read ().split ('\n ' )
1221
1220
assert 'Requires-Python: >=2.7.12' in pkg_info_lines
1222
1221
assert self ._extract_mv_version (pkg_info_lines ) >= (1 , 2 )
1223
1222
@@ -1277,8 +1276,8 @@ def test_egg_info_tag_only_once(self, tmpdir_cwd, env):
1277
1276
})
1278
1277
self ._run_egg_info_command (tmpdir_cwd , env )
1279
1278
egg_info_dir = os .path .join ('.' , 'foo.egg-info' )
1280
- with open (os .path .join (egg_info_dir , 'PKG-INFO' ), encoding = "utf-8" ) as pkginfo_file :
1281
- pkg_info_lines = pkginfo_file .read ().split ('\n ' )
1279
+ with open (os .path .join (egg_info_dir , 'PKG-INFO' ), encoding = "utf-8" ) as fp :
1280
+ pkg_info_lines = fp .read ().split ('\n ' )
1282
1281
assert 'Version: 0.0.0.dev0' in pkg_info_lines
1283
1282
1284
1283
0 commit comments