ソースを参照

Correct LocalPath, Path and str usage

Further corrections

Last correction
Adrien Ferrand 6 年 前
コミット
cfc1acbd30

+ 0 - 1
nsist/tests/test_commands.py

@@ -12,7 +12,6 @@ cmds = {'acommand': {'entry_point': 'somemod:somefunc',
                      'extra_preamble': io.StringIO(u'import extra')}}
 
 def test_prepare_bin_dir(tmpdir):
-    tmpdir = Path(tmpdir)
     commands.prepare_bin_directory(tmpdir, cmds)
     assert_is_file(str(tmpdir / 'acommand.exe'))
     script_file = tmpdir / 'acommand-script.py'

+ 6 - 0
nsist/tests/test_copymodules.py

@@ -16,12 +16,14 @@ sample_path = [pjoin(test_dir, 'sample_pkgs'),
 
 
 def test_copy_plain(tmpdir):
+    tmpdir = str(tmpdir)
     copy_modules(['plainmod', 'plainpkg'], tmpdir, '3.3.5', sample_path)
     assert_is_file(pjoin(tmpdir, 'plainmod.py'))
     assert_is_dir(pjoin(tmpdir, 'plainpkg'))
 
 @skip_on_windows
 def test_copy_wrong_platform(tmpdir):
+    tmpdir = str(tmpdir)
     with pytest.raises(ExtensionModuleMismatch, match="will not be usable on Windows"):
         copy_modules(['unix_extmod'], tmpdir, '3.3.5', sample_path)
 
@@ -30,12 +32,14 @@ def test_copy_wrong_platform(tmpdir):
 
 @only_on_windows
 def test_copy_windows(tmpdir):
+    tmpdir = str(tmpdir)
     copy_modules(['win_extmod', 'win_extpkg'], tmpdir, running_python, sample_path)
     assert_is_file(pjoin(tmpdir, 'win_extmod.pyd'))
     assert_is_dir(pjoin(tmpdir, 'win_extpkg'))
 
 @only_on_windows
 def test_copy_wrong_pyversion(tmpdir):
+    tmpdir = str(tmpdir)
     with pytest.raises(ExtensionModuleMismatch, match="on Python 4"):
         copy_modules(['win_extpkg'], tmpdir, '4.0.0', sample_path)
 
@@ -43,6 +47,7 @@ def test_copy_wrong_pyversion(tmpdir):
         copy_modules(['win_extmod'], tmpdir, '4.0.0', sample_path)
 
 def test_copy_from_zipfile(tmpdir):
+    tmpdir = str(tmpdir)
     copy_modules(['zippedmod2', 'zippedpkg2'],
                  tmpdir, running_python, sample_path)
 #        assert_is_file(pjoin(tmpdir, 'zippedmod.py'))
@@ -51,5 +56,6 @@ def test_copy_from_zipfile(tmpdir):
     assert_is_dir(pjoin(tmpdir, 'zippedpkg2'))
 
 def test_module_not_found(tmpdir):
+    tmpdir = str(tmpdir)
     with pytest.raises(ImportError):
         copy_modules(['nonexistant'], tmpdir, '3.3.5', sample_path)

+ 1 - 0
nsist/tests/test_installerbuilder.py

@@ -9,6 +9,7 @@ from .utils import assert_is_file, test_dir
 sample_preamble = pjoin(test_dir, u'sample_preamble.py')
 
 def test_prepare_shortcuts(tmpdir):
+    tmpdir = str(tmpdir)
     shortcuts = {'sc1': {'entry_point': 'norwegian.blue:parrot',
                          'icon': DEFAULT_ICON,
                          'console': False,

+ 12 - 12
nsist/tests/test_local_wheels.py

@@ -12,8 +12,8 @@ from .utils import assert_is_dir, assert_is_file
 
 @pytest.mark.network
 def test_matching_one_pattern(tmpdir):
-    td1 = tmpdir.mkdir('wheels')
-    td2 = tmpdir.mkdir('pkgs')
+    td1 = str(tmpdir.mkdir('wheels'))
+    td2 = str(tmpdir.mkdir('pkgs'))
 
     subprocess.call(['pip', 'wheel', 'requests==2.19.1', '-w', str(td1)])
 
@@ -27,8 +27,8 @@ def test_matching_one_pattern(tmpdir):
 
 @pytest.mark.network
 def test_duplicate_wheel_files_raise(tmpdir):
-    td1 = tmpdir.mkdir('wheels')
-    td2 = tmpdir.mkdir('pkgs')
+    td1 = str(tmpdir.mkdir('wheels'))
+    td2 = str(tmpdir.mkdir('pkgs'))
 
     subprocess.call(['pip', 'wheel', 'requests==2.19.1', '-w', str(td1)])
 
@@ -37,8 +37,8 @@ def test_duplicate_wheel_files_raise(tmpdir):
                           [os.path.join(td1, '*.whl')], td2, platform.python_version(), 64)
 
 def test_invalid_wheel_file_raise(tmpdir):
-    td1 = tmpdir.mkdir('wheels')
-    td2 = tmpdir.mkdir('pkgs')
+    td1 = str(tmpdir.mkdir('wheels'))
+    td2 = str(tmpdir.mkdir('pkgs'))
 
     open(os.path.join(td1, 'notawheel.txt'), 'w+')
 
@@ -46,8 +46,8 @@ def test_invalid_wheel_file_raise(tmpdir):
         fetch_pypi_wheels([], [os.path.join(td1, '*')], td2, platform.python_version(), 64)
 
 def test_incompatible_plateform_wheel_file_raise(tmpdir):
-    td1 = tmpdir.mkdir('wheels')
-    td2 = tmpdir.mkdir('pkgs')
+    td1 = str(tmpdir.mkdir('wheels'))
+    td2 = str(tmpdir.mkdir('pkgs'))
 
     open(os.path.join(td1, 'incompatiblewheel-1.0.0-py2.py3-none-linux_x86_64.whl'), 'w+')
 
@@ -57,8 +57,8 @@ def test_incompatible_plateform_wheel_file_raise(tmpdir):
         fetch_pypi_wheels([], [os.path.join(td1, '*.whl')], td2, platform.python_version(), 64)
 
 def test_incompatible_python_wheel_file_raise(tmpdir):
-    td1 = tmpdir.mkdir('wheels')
-    td2 = tmpdir.mkdir('pkgs')
+    td1 = str(tmpdir.mkdir('wheels'))
+    td2 = str(tmpdir.mkdir('pkgs'))
 
     open(os.path.join(td1, 'incompatiblewheel-1.0.0-py26-none-any.whl'), 'w+')
 
@@ -68,8 +68,8 @@ def test_incompatible_python_wheel_file_raise(tmpdir):
         fetch_pypi_wheels([], [os.path.join(td1, '*.whl')], td2, platform.python_version(), 64)
 
 def test_useless_wheel_glob_path_raise(tmpdir):
-    td1 = tmpdir.mkdir('wheels')
-    td2 = tmpdir.mkdir('pkgs')
+    td1 = str(tmpdir.mkdir('wheels'))
+    td2 = str(tmpdir.mkdir('pkgs'))
 
     with pytest.raises(ValueError, match='does not match any wheel file'):
         fetch_pypi_wheels([], [os.path.join(td1, '*.whl')], td2, platform.python_version(), 64)

+ 6 - 10
nsist/tests/test_pypi.py

@@ -11,6 +11,7 @@ from .utils import assert_is_file
 
 @pytest.mark.network
 def test_download(tmpdir):
+    tmpdir = str(tmpdir)
     wd = WheelLocator("astsearch==0.1.2", "3.5.1", 64)
     wheel = wd.fetch()
     assert_is_file(str(wheel))
@@ -33,10 +34,8 @@ def test_bad_version():
         wl.get_from_pypi()
 
 def test_extra_sources(tmpdir):
-    src1 = Path(tmpdir, 'src1')
-    src1.mkdir()
-    src2 = Path(tmpdir, 'src2')
-    src2.mkdir()
+    src1 = Path(str(tmpdir.mkdir('src1')))
+    src2 = Path(str(tmpdir.mkdir('src2')))
 
     # First one found wins, even if a later one is more specific.
     expected = (src1 / 'astsearch-0.1.2-py3-none-any.whl')
@@ -112,12 +111,9 @@ def test_pick_best_wheel():
     ]
     assert wd.pick_best_wheel(releases) == releases[1]
 
-def test_merge_dir_to(tmpdir_factory):
-    td1 = tmpdir_factory.mktemp('td1')
-    td2 = tmpdir_factory.mktemp('td2')
-
-    td1 = Path(td1)
-    td2 = Path(td2)
+def test_merge_dir_to(tmpdir):
+    td1 = Path(str(tmpdir.mkdir('one')))
+    td2 = Path(str(tmpdir.mkdir('two')))
 
     with (td1 / 'ab').open('w') as f:
         f.write(u"original")