Skip to content

Commit

Permalink
Fix linting and types
Browse files Browse the repository at this point in the history
  • Loading branch information
karthiknadig committed Sep 23, 2024
1 parent 9d22442 commit 6443b47
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
2 changes: 1 addition & 1 deletion python_files/create_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def upgrade_pip(venv_path: str) -> None:

def create_gitignore(git_ignore: Union[str, pathlib.PurePath]):
print("Creating:", os.fspath(git_ignore))
git_ignore.write_text("*")
pathlib.Path(git_ignore).write_text("*")


def add_gitignore(name: str) -> None:
Expand Down
24 changes: 6 additions & 18 deletions python_files/tests/test_create_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
import create_venv


@pytest.mark.skipif(
sys.platform == "win32", reason="Windows does not have micro venv fallback."
)
@pytest.mark.skipif(sys.platform == "win32", reason="Windows does not have micro venv fallback.")
def test_venv_not_installed_unix():
importlib.reload(create_venv)
create_venv.is_installed = lambda module: module != "venv"
Expand All @@ -43,9 +41,7 @@ def run_process(args, error_message):
assert run_process_called is True


@pytest.mark.skipif(
sys.platform != "win32", reason="Windows does not have microvenv fallback."
)
@pytest.mark.skipif(sys.platform != "win32", reason="Windows does not have microvenv fallback.")
def test_venv_not_installed_windows():
importlib.reload(create_venv)
create_venv.is_installed = lambda module: module != "venv"
Expand All @@ -55,9 +51,7 @@ def test_venv_not_installed_windows():


@pytest.mark.parametrize("env_exists", ["hasEnv", "noEnv"])
@pytest.mark.parametrize(
"git_ignore", ["useGitIgnore", "skipGitIgnore", "gitIgnoreExists"]
)
@pytest.mark.parametrize("git_ignore", ["useGitIgnore", "skipGitIgnore", "gitIgnoreExists"])
@pytest.mark.parametrize("install", ["requirements", "toml", "skipInstall"])
def test_create_env(env_exists, git_ignore, install):
importlib.reload(create_venv)
Expand Down Expand Up @@ -119,13 +113,9 @@ def create_gitignore(_p):
assert run_process_called == (env_exists == "noEnv")

# add_gitignore is called when new venv is created and git_ignore is True
assert add_gitignore_called == (
(env_exists == "noEnv") and (git_ignore == "useGitIgnore")
)
assert add_gitignore_called == ((env_exists == "noEnv") and (git_ignore == "useGitIgnore"))

assert create_gitignore_called == (
add_gitignore_called and (git_ignore != "gitIgnoreExists")
)
assert create_gitignore_called == (add_gitignore_called and (git_ignore != "gitIgnoreExists"))


@pytest.mark.parametrize("install_type", ["requirements", "pyproject", "both"])
Expand Down Expand Up @@ -255,9 +245,7 @@ def run_process(args, error_message):
if "install" in args and "pip" in args:
nonlocal run_process_called
run_process_called = True
pip_pyz_path = os.fspath(
create_venv.CWD / create_venv.VENV_NAME / "pip.pyz"
)
pip_pyz_path = os.fspath(create_venv.CWD / create_venv.VENV_NAME / "pip.pyz")
assert args[1:] == [pip_pyz_path, "install", "pip"]
assert error_message == "CREATE_VENV.INSTALL_PIP_FAILED"

Expand Down

0 comments on commit 6443b47

Please sign in to comment.