Skip to content

Rename compatible functions in tests.lib.path.Path. #6670

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added news/pathlib-refactor-2.trivial
Empty file.
16 changes: 9 additions & 7 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def not_code_files_and_folders(path, names):
ignored.extend(fnmatch.filter(names, pattern))
return set(ignored)

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

# Create the virtual environment
tmpdir = Path(str(tmpdir_factory.mktemp('virtualenv')))
venv = VirtualEnvironment(tmpdir.join("venv_orig"), venv_type=venv_type)
venv = VirtualEnvironment(
tmpdir.joinpath("venv_orig"), venv_type=venv_type
)

# Install setuptools and pip.
install_egg_link(venv, 'setuptools', setuptools_install)
Expand All @@ -248,7 +250,7 @@ def virtualenv_template(request, tmpdir_factory, pip_src,
exe.startswith('python') or
exe.startswith('libpy') # Don't remove libpypy-c.so...
):
(venv.bin / exe).remove()
(venv.bin / exe).unlink()

# Enable user site packages.
venv.user_site_packages = True
Expand All @@ -268,7 +270,7 @@ def virtualenv(virtualenv_template, tmpdir, isolate):
temporary directory. The returned object is a
``tests.lib.venv.VirtualEnvironment`` object.
"""
venv_location = tmpdir.join("workspace", "venv")
venv_location = tmpdir.joinpath("workspace", "venv")
yield VirtualEnvironment(venv_location, virtualenv_template)


Expand All @@ -287,7 +289,7 @@ def script(tmpdir, virtualenv, deprecated_python):
"""
return PipTestEnvironment(
# The base location for our test environment
tmpdir.join("workspace"),
tmpdir.joinpath("workspace"),

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


@pytest.fixture
def data(tmpdir):
return TestData.copy(tmpdir.join("data"))
return TestData.copy(tmpdir.joinpath("data"))


class InMemoryPipResult(object):
Expand Down
16 changes: 8 additions & 8 deletions tests/functional/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@


def fake_wheel(data, wheel_path):
data.packages.join(
data.packages.joinpath(
'simple.dist-0.1-py2.py3-none-any.whl'
).copy(data.packages.join(wheel_path))
).copy(data.packages.joinpath(wheel_path))


@pytest.mark.network
Expand Down Expand Up @@ -61,7 +61,7 @@ def test_single_download_from_requirements_file(script):
It should support download (in the scratch path) from PyPI from a
requirements file
"""
script.scratch_path.join("test-req.txt").write(textwrap.dedent("""
script.scratch_path.joinpath("test-req.txt").write_text(textwrap.dedent("""
INITools==0.1
"""))
result = script.pip(
Expand Down Expand Up @@ -121,7 +121,7 @@ def test_download_should_skip_existing_files(script):
"""
It should not download files already existing in the scratch dir
"""
script.scratch_path.join("test-req.txt").write(textwrap.dedent("""
script.scratch_path.joinpath("test-req.txt").write_text(textwrap.dedent("""
INITools==0.1
"""))

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

# adding second package to test-req.txt
script.scratch_path.join("test-req.txt").write(textwrap.dedent("""
script.scratch_path.joinpath("test-req.txt").write_text(textwrap.dedent("""
INITools==0.1
python-openid==2.2.5
"""))
Expand Down Expand Up @@ -493,7 +493,7 @@ def make_wheel_with_python_requires(script, package_name, python_requires):
python_requires='{}',
version='1.0')
""").format(package_name, python_requires)
package_dir.join('setup.py').write(text)
package_dir.joinpath('setup.py').write_text(text)
script.run(
'python', 'setup.py', 'bdist_wheel', '--universal', cwd=package_dir,
)
Expand Down Expand Up @@ -674,7 +674,7 @@ def test_download_exit_status_code_when_blank_requirements_file(script):
"""
Test download exit status code when blank requirements file specified
"""
script.scratch_path.join("blank.txt").write("\n")
script.scratch_path.joinpath("blank.txt").write_text("\n")
script.pip('download', '-r', 'blank.txt')


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

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

Expand Down
18 changes: 9 additions & 9 deletions tests/functional/test_freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_basic_freeze(script):
currently it is not).

"""
script.scratch_path.join("initools-req.txt").write(textwrap.dedent("""\
script.scratch_path.joinpath("initools-req.txt").write_text(textwrap.dedent("""\
simple==2.0
# and something else to test out:
simple2<=3.0
Expand Down Expand Up @@ -476,8 +476,8 @@ def test_freeze_with_requirement_option_file_url_egg_not_installed(
"""

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

result = script.pip(
'freeze', '--requirement', 'requirements.txt', expect_stderr=True,
Expand All @@ -498,7 +498,7 @@ def test_freeze_with_requirement_option(script):

"""

script.scratch_path.join("hint.txt").write(textwrap.dedent("""\
script.scratch_path.joinpath("hint.txt").write_text(textwrap.dedent("""\
INITools==0.1
NoExist==4.2 # A comment that ensures end of line comments work.
simple==3.0; python_version > '1.0'
Expand Down Expand Up @@ -528,12 +528,12 @@ def test_freeze_with_requirement_option_multiple(script):
--requirement hints

"""
script.scratch_path.join('hint1.txt').write(textwrap.dedent("""\
script.scratch_path.joinpath('hint1.txt').write_text(textwrap.dedent("""\
INITools==0.1
NoExist==4.2
simple==3.0; python_version > '1.0'
""") + _freeze_req_opts)
script.scratch_path.join('hint2.txt').write(textwrap.dedent("""\
script.scratch_path.joinpath('hint2.txt').write_text(textwrap.dedent("""\
NoExist2==2.0
simple2==1.0
""") + _freeze_req_opts)
Expand Down Expand Up @@ -576,7 +576,7 @@ def test_freeze_with_requirement_option_package_repeated_one_file(script):
Test freezing with single requirements file that contains a package
multiple times
"""
script.scratch_path.join('hint1.txt').write(textwrap.dedent("""\
script.scratch_path.joinpath('hint1.txt').write_text(textwrap.dedent("""\
simple2
simple2
NoExist
Expand Down Expand Up @@ -609,10 +609,10 @@ def test_freeze_with_requirement_option_package_repeated_multi_file(script):
"""
Test freezing with multiple requirements file that contain a package
"""
script.scratch_path.join('hint1.txt').write(textwrap.dedent("""\
script.scratch_path.joinpath('hint1.txt').write_text(textwrap.dedent("""\
simple
""") + _freeze_req_opts)
script.scratch_path.join('hint2.txt').write(textwrap.dedent("""\
script.scratch_path.joinpath('hint2.txt').write_text(textwrap.dedent("""\
simple
NoExist
""") + _freeze_req_opts)
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/test_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ def test_bad_algo_option(script, tmpdir):
def _hello_file(tmpdir):
"""Return a temp file to hash containing "hello"."""
file = tmpdir / 'hashable'
file.write('hello')
file.write_text('hello')
return file
Loading