Browse Source

Switch tests to tmp_path fixture, fix Python 3.5 compatibility

Thomas Kluyver 5 years ago
parent
commit
9e52adfd97
2 changed files with 7 additions and 7 deletions
  1. 1 1
      nsist/commands.py
  2. 6 6
      nsist/tests/test_commands.py

+ 1 - 1
nsist/commands.py

@@ -68,7 +68,7 @@ def prepare_bin_directory(target, commands, bitness=32):
             zf.writestr('__main__.py', script.encode('utf-8'))
 
         # Put the pieces together
-        with open(exe_path, 'wb') as f:
+        with exe_path.open('wb') as f:
             f.write(launcher_b)
             f.write(shebang)
             f.write(zip_bio.getvalue())

+ 6 - 6
nsist/tests/test_commands.py

@@ -4,16 +4,16 @@ from zipfile import ZipFile
 
 from nsist import commands
 
-def test_prepare_bin_dir(tmpdir):
+def test_prepare_bin_dir(tmp_path):
     cmds = {
         'acommand': {
             'entry_point': 'somemod:somefunc',
             'extra_preamble': io.StringIO(u'import extra')
         }
     }
-    commands.prepare_bin_directory(tmpdir, cmds)
+    commands.prepare_bin_directory(tmp_path, cmds)
 
-    exe_file = str(tmpdir / 'acommand.exe')
+    exe_file = str(tmp_path / 'acommand.exe')
 
     assert_isfile(exe_file)
 
@@ -32,16 +32,16 @@ def test_prepare_bin_dir(tmpdir):
     assert 'import extra' in script_contents
     assert 'somefunc()' in script_contents
 
-def test_prepare_bin_dir_noconsole(tmpdir):
+def test_prepare_bin_dir_noconsole(tmp_path):
     cmds = {
         'acommand': {
             'entry_point': 'somemod:somefunc',
             'console': False
         }
     }
-    commands.prepare_bin_directory(tmpdir, cmds)
+    commands.prepare_bin_directory(tmp_path, cmds)
 
-    exe_file = str(tmpdir / 'acommand.exe')
+    exe_file = str(tmp_path / 'acommand.exe')
 
     assert_isfile(exe_file)