Skip to content

Commit 39ac9ca

Browse files
committed
Rename compatible functions in tests.lib.path.Path.
1 parent ec73d72 commit 39ac9ca

39 files changed

+364
-351
lines changed

news/pathlib-refactor-2.trivial

Whitespace-only changes.

tests/conftest.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def not_code_files_and_folders(path, names):
180180
ignored.extend(fnmatch.filter(names, pattern))
181181
return set(ignored)
182182

183-
pip_src = Path(str(tmpdir_factory.mktemp('pip_src'))).join('pip_src')
183+
pip_src = Path(str(tmpdir_factory.mktemp('pip_src'))).joinpath('pip_src')
184184
# Copy over our source tree so that each use is self contained
185185
shutil.copytree(
186186
SRC_DIR,
@@ -232,7 +232,9 @@ def virtualenv_template(request, tmpdir_factory, pip_src,
232232

233233
# Create the virtual environment
234234
tmpdir = Path(str(tmpdir_factory.mktemp('virtualenv')))
235-
venv = VirtualEnvironment(tmpdir.join("venv_orig"), venv_type=venv_type)
235+
venv = VirtualEnvironment(
236+
tmpdir.joinpath("venv_orig"), venv_type=venv_type
237+
)
236238

237239
# Install setuptools and pip.
238240
install_egg_link(venv, 'setuptools', setuptools_install)
@@ -248,7 +250,7 @@ def virtualenv_template(request, tmpdir_factory, pip_src,
248250
exe.startswith('python') or
249251
exe.startswith('libpy') # Don't remove libpypy-c.so...
250252
):
251-
(venv.bin / exe).remove()
253+
(venv.bin / exe).unlink()
252254

253255
# Enable user site packages.
254256
venv.user_site_packages = True
@@ -268,7 +270,7 @@ def virtualenv(virtualenv_template, tmpdir, isolate):
268270
temporary directory. The returned object is a
269271
``tests.lib.venv.VirtualEnvironment`` object.
270272
"""
271-
venv_location = tmpdir.join("workspace", "venv")
273+
venv_location = tmpdir.joinpath("workspace", "venv")
272274
yield VirtualEnvironment(venv_location, virtualenv_template)
273275

274276

@@ -287,7 +289,7 @@ def script(tmpdir, virtualenv, deprecated_python):
287289
"""
288290
return PipTestEnvironment(
289291
# The base location for our test environment
290-
tmpdir.join("workspace"),
292+
tmpdir.joinpath("workspace"),
291293

292294
# Tell the Test Environment where our virtualenv is located
293295
virtualenv=virtualenv,
@@ -311,12 +313,12 @@ def script(tmpdir, virtualenv, deprecated_python):
311313
@pytest.fixture(scope="session")
312314
def common_wheels():
313315
"""Provide a directory with latest setuptools and wheel wheels"""
314-
return DATA_DIR.join('common_wheels')
316+
return DATA_DIR.joinpath('common_wheels')
315317

316318

317319
@pytest.fixture
318320
def data(tmpdir):
319-
return TestData.copy(tmpdir.join("data"))
321+
return TestData.copy(tmpdir.joinpath("data"))
320322

321323

322324
class InMemoryPipResult(object):

tests/functional/test_download.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99

1010
def fake_wheel(data, wheel_path):
11-
data.packages.join(
11+
data.packages.joinpath(
1212
'simple.dist-0.1-py2.py3-none-any.whl'
13-
).copy(data.packages.join(wheel_path))
13+
).copy(data.packages.joinpath(wheel_path))
1414

1515

1616
@pytest.mark.network
@@ -61,7 +61,7 @@ def test_single_download_from_requirements_file(script):
6161
It should support download (in the scratch path) from PyPI from a
6262
requirements file
6363
"""
64-
script.scratch_path.join("test-req.txt").write(textwrap.dedent("""
64+
script.scratch_path.joinpath("test-req.txt").write_text(textwrap.dedent("""
6565
INITools==0.1
6666
"""))
6767
result = script.pip(
@@ -121,7 +121,7 @@ def test_download_should_skip_existing_files(script):
121121
"""
122122
It should not download files already existing in the scratch dir
123123
"""
124-
script.scratch_path.join("test-req.txt").write(textwrap.dedent("""
124+
script.scratch_path.joinpath("test-req.txt").write_text(textwrap.dedent("""
125125
INITools==0.1
126126
"""))
127127

@@ -133,7 +133,7 @@ def test_download_should_skip_existing_files(script):
133133
assert script.site_packages / 'initools' not in result.files_created
134134

135135
# adding second package to test-req.txt
136-
script.scratch_path.join("test-req.txt").write(textwrap.dedent("""
136+
script.scratch_path.joinpath("test-req.txt").write_text(textwrap.dedent("""
137137
INITools==0.1
138138
python-openid==2.2.5
139139
"""))
@@ -493,7 +493,7 @@ def make_wheel_with_python_requires(script, package_name, python_requires):
493493
python_requires='{}',
494494
version='1.0')
495495
""").format(package_name, python_requires)
496-
package_dir.join('setup.py').write(text)
496+
package_dir.joinpath('setup.py').write_text(text)
497497
script.run(
498498
'python', 'setup.py', 'bdist_wheel', '--universal', cwd=package_dir,
499499
)
@@ -674,7 +674,7 @@ def test_download_exit_status_code_when_blank_requirements_file(script):
674674
"""
675675
Test download exit status code when blank requirements file specified
676676
"""
677-
script.scratch_path.join("blank.txt").write("\n")
677+
script.scratch_path.joinpath("blank.txt").write_text("\n")
678678
script.pip('download', '-r', 'blank.txt')
679679

680680

@@ -699,7 +699,7 @@ def test_download_prefer_binary_when_tarball_higher_than_wheel(script, data):
699699

700700
def test_download_prefer_binary_when_wheel_doesnt_satisfy_req(script, data):
701701
fake_wheel(data, 'source-0.8-py2.py3-none-any.whl')
702-
script.scratch_path.join("test-req.txt").write(textwrap.dedent("""
702+
script.scratch_path.joinpath("test-req.txt").write_text(textwrap.dedent("""
703703
source>0.9
704704
"""))
705705

tests/functional/test_freeze.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def test_basic_freeze(script):
5151
currently it is not).
5252
5353
"""
54-
script.scratch_path.join("initools-req.txt").write(textwrap.dedent("""\
54+
script.scratch_path.joinpath("initools-req.txt").write_text(textwrap.dedent("""\
5555
simple==2.0
5656
# and something else to test out:
5757
simple2<=3.0
@@ -476,8 +476,8 @@ def test_freeze_with_requirement_option_file_url_egg_not_installed(
476476
"""
477477

478478
url = path_to_url('my-package.tar.gz') + '#egg=Does.Not-Exist'
479-
requirements_path = script.scratch_path.join('requirements.txt')
480-
requirements_path.write(url + '\n')
479+
requirements_path = script.scratch_path.joinpath('requirements.txt')
480+
requirements_path.write_text(url + '\n')
481481

482482
result = script.pip(
483483
'freeze', '--requirement', 'requirements.txt', expect_stderr=True,
@@ -498,7 +498,7 @@ def test_freeze_with_requirement_option(script):
498498
499499
"""
500500

501-
script.scratch_path.join("hint.txt").write(textwrap.dedent("""\
501+
script.scratch_path.joinpath("hint.txt").write_text(textwrap.dedent("""\
502502
INITools==0.1
503503
NoExist==4.2 # A comment that ensures end of line comments work.
504504
simple==3.0; python_version > '1.0'
@@ -528,12 +528,12 @@ def test_freeze_with_requirement_option_multiple(script):
528528
--requirement hints
529529
530530
"""
531-
script.scratch_path.join('hint1.txt').write(textwrap.dedent("""\
531+
script.scratch_path.joinpath('hint1.txt').write_text(textwrap.dedent("""\
532532
INITools==0.1
533533
NoExist==4.2
534534
simple==3.0; python_version > '1.0'
535535
""") + _freeze_req_opts)
536-
script.scratch_path.join('hint2.txt').write(textwrap.dedent("""\
536+
script.scratch_path.joinpath('hint2.txt').write_text(textwrap.dedent("""\
537537
NoExist2==2.0
538538
simple2==1.0
539539
""") + _freeze_req_opts)
@@ -576,7 +576,7 @@ def test_freeze_with_requirement_option_package_repeated_one_file(script):
576576
Test freezing with single requirements file that contains a package
577577
multiple times
578578
"""
579-
script.scratch_path.join('hint1.txt').write(textwrap.dedent("""\
579+
script.scratch_path.joinpath('hint1.txt').write_text(textwrap.dedent("""\
580580
simple2
581581
simple2
582582
NoExist
@@ -609,10 +609,10 @@ def test_freeze_with_requirement_option_package_repeated_multi_file(script):
609609
"""
610610
Test freezing with multiple requirements file that contain a package
611611
"""
612-
script.scratch_path.join('hint1.txt').write(textwrap.dedent("""\
612+
script.scratch_path.joinpath('hint1.txt').write_text(textwrap.dedent("""\
613613
simple
614614
""") + _freeze_req_opts)
615-
script.scratch_path.join('hint2.txt').write(textwrap.dedent("""\
615+
script.scratch_path.joinpath('hint2.txt').write_text(textwrap.dedent("""\
616616
simple
617617
NoExist
618618
""") + _freeze_req_opts)

tests/functional/test_hash.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ def test_bad_algo_option(script, tmpdir):
2828
def _hello_file(tmpdir):
2929
"""Return a temp file to hash containing "hello"."""
3030
file = tmpdir / 'hashable'
31-
file.write('hello')
31+
file.write_text('hello')
3232
return file

0 commit comments

Comments
 (0)