mirror of https://github.com/pypa/hatch.git
50 lines
1.5 KiB
Python
50 lines
1.5 KiB
Python
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
|
|
|
|
|
|
@requires_internet
|
|
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')
|