Skip to content

Commit

Permalink
Fix test_env.py formatting with black.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaharkes committed Dec 10, 2020
1 parent a59959a commit d0bf642
Showing 1 changed file with 17 additions and 41 deletions.
58 changes: 17 additions & 41 deletions tests/utils/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,7 @@ def test_activate_activates_non_existing_virtualenv_no_envs_file(

config.merge({"virtualenvs": {"path": str(tmp_dir)}})

mocker.patch(
"subprocess.check_output", side_effect=check_output_wrapper(),
)
mocker.patch("subprocess.check_output", side_effect=check_output_wrapper())
mocker.patch(
"subprocess.Popen.communicate",
side_effect=[("/prefix", None), ("/prefix", None)],
Expand Down Expand Up @@ -183,12 +181,8 @@ def test_activate_activates_existing_virtualenv_no_envs_file(

config.merge({"virtualenvs": {"path": str(tmp_dir)}})

mocker.patch(
"subprocess.check_output", side_effect=check_output_wrapper(),
)
mocker.patch(
"subprocess.Popen.communicate", side_effect=[("/prefix", None)],
)
mocker.patch("subprocess.check_output", side_effect=check_output_wrapper())
mocker.patch("subprocess.Popen.communicate", side_effect=[("/prefix", None)])
m = mocker.patch("poetry.utils.env.EnvManager.build_venv", side_effect=build_venv)

env = manager.activate("python3.7", NullIO())
Expand Down Expand Up @@ -222,12 +216,8 @@ def test_activate_activates_same_virtualenv_with_envs_file(

config.merge({"virtualenvs": {"path": str(tmp_dir)}})

mocker.patch(
"subprocess.check_output", side_effect=check_output_wrapper(),
)
mocker.patch(
"subprocess.Popen.communicate", side_effect=[("/prefix", None)],
)
mocker.patch("subprocess.check_output", side_effect=check_output_wrapper())
mocker.patch("subprocess.Popen.communicate", side_effect=[("/prefix", None)])
m = mocker.patch("poetry.utils.env.EnvManager.create_venv")

env = manager.activate("python3.7", NullIO())
Expand Down Expand Up @@ -302,9 +292,7 @@ def test_activate_activates_recreates_for_different_patch(

config.merge({"virtualenvs": {"path": str(tmp_dir)}})

mocker.patch(
"subprocess.check_output", side_effect=check_output_wrapper(),
)
mocker.patch("subprocess.check_output", side_effect=check_output_wrapper())
mocker.patch(
"subprocess.Popen.communicate",
side_effect=[
Expand Down Expand Up @@ -403,9 +391,7 @@ def test_deactivate_non_activated_but_existing(

config.merge({"virtualenvs": {"path": str(tmp_dir)}})

mocker.patch(
"subprocess.check_output", side_effect=check_output_wrapper(),
)
mocker.patch("subprocess.check_output", side_effect=check_output_wrapper())

manager.deactivate(NullIO())
env = manager.get()
Expand Down Expand Up @@ -441,9 +427,7 @@ def test_deactivate_activated(tmp_dir, manager, poetry, config, mocker):

config.merge({"virtualenvs": {"path": str(tmp_dir)}})

mocker.patch(
"subprocess.check_output", side_effect=check_output_wrapper(),
)
mocker.patch("subprocess.check_output", side_effect=check_output_wrapper())

manager.deactivate(NullIO())
env = manager.get()
Expand Down Expand Up @@ -472,12 +456,8 @@ def test_get_prefers_explicitly_activated_virtualenvs_over_env_var(
doc[venv_name] = {"minor": "3.7", "patch": "3.7.0"}
envs_file.write(doc)

mocker.patch(
"subprocess.check_output", side_effect=check_output_wrapper(),
)
mocker.patch(
"subprocess.Popen.communicate", side_effect=[("/prefix", None)],
)
mocker.patch("subprocess.check_output", side_effect=check_output_wrapper())
mocker.patch("subprocess.Popen.communicate", side_effect=[("/prefix", None)])

env = manager.get()

Expand Down Expand Up @@ -813,9 +793,7 @@ def test_activate_with_in_project_setting_does_not_fail_if_no_venvs_dir(
}
)

mocker.patch(
"subprocess.check_output", side_effect=check_output_wrapper(),
)
mocker.patch("subprocess.check_output", side_effect=check_output_wrapper())
mocker.patch(
"subprocess.Popen.communicate",
side_effect=[("/prefix", None), ("/prefix", None)],
Expand Down Expand Up @@ -845,9 +823,7 @@ def test_system_env_has_correct_paths():
assert env.site_packages.path == Path(paths["purelib"])


@pytest.mark.parametrize(
("enabled",), [(True,), (False,)],
)
@pytest.mark.parametrize(("enabled",), [(True,), (False,)])
def test_system_env_usersite(mocker, enabled):
mocker.patch("site.check_enableusersite", return_value=enabled)
env = SystemEnv(Path(sys.prefix))
Expand Down Expand Up @@ -876,19 +852,19 @@ def test_create_venv_accepts_fallback_version_w_nonzero_patchlevel(

check_output = mocker.patch(
"subprocess.check_output",
side_effect=lambda cmd, *args, **kwargs: str("3.5.12" if "python3.5" in cmd else "3.7.1")
side_effect=lambda cmd, *args, **kwargs: str(
"3.5.12" if "python3.5" in cmd else "3.7.1"
),
)
m = mocker.patch(
"poetry.utils.env.EnvManager.build_venv", side_effect=lambda *args, **kwargs: ""
)

manager.create_venv(NullIO()
)
manager.create_venv(NullIO())

assert check_output.called
m.assert_called_with(
config_virtualenvs_path
/ "{}-py3.5".format(venv_name),
config_virtualenvs_path / "{}-py3.5".format(venv_name),
executable="python3.5",
flags={"always-copy": False},
)

0 comments on commit d0bf642

Please sign in to comment.