11import re
22import json
33import pickle
4- import textwrap
54import unittest
65import warnings
76import importlib
@@ -82,11 +81,12 @@ def pkg_with_dashes(site_dir):
8281 Create minimal metadata for a package with dashes
8382 in the name (and thus underscores in the filename).
8483 """
85- metadata_dir = site_dir / 'my_pkg.dist-info'
86- metadata_dir .mkdir ()
87- metadata = metadata_dir / 'METADATA'
88- with metadata .open ('w' , encoding = 'utf-8' ) as strm :
89- strm .write ('Version: 1.0\n ' )
84+ contents = {
85+ 'my_pkg.dist-info' : {
86+ 'METADATA' : 'VERSION: 1.0\n ' ,
87+ },
88+ }
89+ fixtures .build_files (contents , site_dir )
9090 return 'my-pkg'
9191
9292 def test_dashes_in_dist_name_found_as_underscores (self ):
@@ -103,11 +103,12 @@ def pkg_with_mixed_case(site_dir):
103103 Create minimal metadata for a package with mixed case
104104 in the name.
105105 """
106- metadata_dir = site_dir / 'CherryPy.dist-info'
107- metadata_dir .mkdir ()
108- metadata = metadata_dir / 'METADATA'
109- with metadata .open ('w' , encoding = 'utf-8' ) as strm :
110- strm .write ('Version: 1.0\n ' )
106+ contents = {
107+ 'CherryPy.dist-info' : {
108+ 'METADATA' : 'VERSION: 1.0\n ' ,
109+ },
110+ }
111+ fixtures .build_files (contents , site_dir )
111112 return 'CherryPy'
112113
113114 def test_dist_name_found_as_any_case (self ):
@@ -127,11 +128,12 @@ def pkg_with_non_ascii_description(site_dir):
127128 Create minimal metadata for a package with non-ASCII in
128129 the description.
129130 """
130- metadata_dir = site_dir / 'portend.dist-info'
131- metadata_dir .mkdir ()
132- metadata = metadata_dir / 'METADATA'
133- with metadata .open ('w' , encoding = 'utf-8' ) as fp :
134- fp .write ('Description: pôrˈtend' )
131+ contents = {
132+ 'portend.dist-info' : {
133+ 'METADATA' : 'Description: pôrˈtend' ,
134+ },
135+ }
136+ fixtures .build_files (contents , site_dir )
135137 return 'portend'
136138
137139 @staticmethod
@@ -140,19 +142,15 @@ def pkg_with_non_ascii_description_egg_info(site_dir):
140142 Create minimal metadata for an egg-info package with
141143 non-ASCII in the description.
142144 """
143- metadata_dir = site_dir / 'portend.dist-info'
144- metadata_dir .mkdir ()
145- metadata = metadata_dir / 'METADATA'
146- with metadata .open ('w' , encoding = 'utf-8' ) as fp :
147- fp .write (
148- textwrap .dedent (
149- """
145+ contents = {
146+ 'portend.dist-info' : {
147+ 'METADATA' : """
150148 Name: portend
151149
152- pôrˈtend
153- """
154- ). strip ()
155- )
150+ pôrˈtend""" ,
151+ },
152+ }
153+ fixtures . build_files ( contents , site_dir )
156154 return 'portend'
157155
158156 def test_metadata_loads (self ):
0 commit comments