aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2015-01-01 11:03:18 -0500
committerJason R. Coombs <jaraco@jaraco.com>2015-01-01 11:03:18 -0500
commitaee1868928e70bc6fdbd91649d596380646bf481 (patch)
tree4d689c515cfc0683e066c586419063eb00029fbe /setuptools
parenta75c16ed451046c6c642fb818fe96af55171355e (diff)
downloadexternal_python_setuptools-aee1868928e70bc6fdbd91649d596380646bf481.tar.gz
external_python_setuptools-aee1868928e70bc6fdbd91649d596380646bf481.tar.bz2
external_python_setuptools-aee1868928e70bc6fdbd91649d596380646bf481.zip
Simplify script creation with context managers and leveraging local variables for the template population.
Diffstat (limited to 'setuptools')
-rw-r--r--setuptools/tests/test_windows_wrappers.py18
1 files changed, 7 insertions, 11 deletions
diff --git a/setuptools/tests/test_windows_wrappers.py b/setuptools/tests/test_windows_wrappers.py
index 91012917..92e9f882 100644
--- a/setuptools/tests/test_windows_wrappers.py
+++ b/setuptools/tests/test_windows_wrappers.py
@@ -37,20 +37,16 @@ class WrapperTester:
"""
sample_directory = tempdir
- script = cls.script_tmpl % dict(python_exe=nt_quote_arg
- (sys.executable))
+ python_exe = nt_quote_arg(sys.executable)
+ script = cls.script_tmpl % locals()
- f = open(os.path.join(sample_directory, cls.script_name), 'w')
- f.write(script)
- f.close()
+ with open(os.path.join(sample_directory, cls.script_name), 'w') as f:
+ f.write(script)
# also copy cli.exe to the sample directory
-
- f = open(os.path.join(sample_directory, cls.wrapper_name), 'wb')
- f.write(
- pkg_resources.resource_string('setuptools', cls.wrapper_source)
- )
- f.close()
+ with open(os.path.join(sample_directory, cls.wrapper_name), 'wb') as f:
+ w = pkg_resources.resource_string('setuptools', cls.wrapper_source)
+ f.write(w)
class TestCLI(WrapperTester):