forked from pypa/hatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_env_utils.py
48 lines (36 loc) · 1.44 KB
/
test_env_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import os
from click.testing import CliRunner
from hatch.cli import hatch
from hatch.env import (
get_editable_package_location, get_installed_packages, get_package_version,
install_packages
)
from hatch.utils import temp_chdir
from hatch.venv import create_venv, venv
from .utils import requires_internet
def test_get_package_version_not_installed():
assert get_package_version('the_knights_who_say_ni') == ''
@requires_internet
def test_get_installed_packages_no_editable():
with temp_chdir() as d:
runner = CliRunner()
runner.invoke(hatch, ['init', 'ok', '--basic', '-ne'])
venv_dir = os.path.join(d, 'venv')
create_venv(venv_dir)
with venv(venv_dir):
install_packages(['six'])
install_packages(['-e', '.'])
packages = get_installed_packages(editable=False)
assert 'six' in packages
assert 'ok' not in packages
def test_get_editable_package_location():
with temp_chdir() as d:
runner = CliRunner()
runner.invoke(hatch, ['new', 'foo', '--basic', '-ne'])
runner.invoke(hatch, ['new', 'bar', '--basic', '-ne'])
venv_dir = os.path.join(d, 'venv')
create_venv(venv_dir)
with venv(venv_dir):
install_packages(['-e', os.path.join(d, 'foo')])
install_packages(['-e', os.path.join(d, 'bar')])
assert get_editable_package_location('foo') == os.path.join(d, 'foo')