1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

Combine tests/functional/test_vcs.py with other test modules.

This commit is contained in:
Chris Jerdonek 2018-07-27 09:17:51 -07:00
parent f115d1fa2d
commit 48b55eb95e
3 changed files with 30 additions and 32 deletions

View file

@ -1,32 +0,0 @@
import os
from pip._internal.utils.temp_dir import TempDirectory
from pip._internal.vcs.git import Git
def test_git_dir_ignored():
"""
Test that a GIT_DIR environment variable is ignored.
"""
git = Git()
with TempDirectory() as temp:
temp_dir = temp.path
env = {'GIT_DIR': 'foo'}
# If GIT_DIR is not ignored, then os.listdir() will return ['foo'].
git.run_command(['init', temp_dir], cwd=temp_dir, extra_environ=env)
assert os.listdir(temp_dir) == ['.git']
def test_git_work_tree_ignored():
"""
Test that a GIT_WORK_TREE environment variable is ignored.
"""
git = Git()
with TempDirectory() as temp:
temp_dir = temp.path
git.run_command(['init', temp_dir], cwd=temp_dir)
# Choose a directory relative to the cwd that does not exist.
# If GIT_WORK_TREE is not ignored, then the command will error out
# with: "fatal: This operation must be run in a work tree".
env = {'GIT_WORK_TREE': 'foo'}
git.run_command(['status', temp_dir], extra_environ=env, cwd=temp_dir)

View file

@ -2,6 +2,8 @@
Contains functional tests of the Git class.
"""
import os
import pytest
from pip._internal.utils.temp_dir import TempDirectory
@ -40,6 +42,34 @@ def check_rev(repo_dir, rev, expected_sha):
assert git.get_revision_sha(repo_dir, rev) == expected_sha
def test_git_dir_ignored():
"""
Test that a GIT_DIR environment variable is ignored.
"""
git = Git()
with TempDirectory() as temp:
temp_dir = temp.path
env = {'GIT_DIR': 'foo'}
# If GIT_DIR is not ignored, then os.listdir() will return ['foo'].
git.run_command(['init', temp_dir], cwd=temp_dir, extra_environ=env)
assert os.listdir(temp_dir) == ['.git']
def test_git_work_tree_ignored():
"""
Test that a GIT_WORK_TREE environment variable is ignored.
"""
git = Git()
with TempDirectory() as temp:
temp_dir = temp.path
git.run_command(['init', temp_dir], cwd=temp_dir)
# Choose a directory relative to the cwd that does not exist.
# If GIT_WORK_TREE is not ignored, then the command will error out
# with: "fatal: This operation must be run in a work tree".
env = {'GIT_WORK_TREE': 'foo'}
git.run_command(['status', temp_dir], extra_environ=env, cwd=temp_dir)
def test_get_revision_sha(script):
with TempDirectory(kind="testing") as temp:
repo_dir = temp.path