forked from lektor/lektor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes installing lokal plugins with extras_require (for testing depen…
…dencies mostly). Fixes lektor#865
- Loading branch information
Showing
2 changed files
with
116 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import os | ||
import shutil | ||
import tempfile | ||
import textwrap | ||
import pathlib | ||
|
||
import pytest | ||
|
||
from lektor import packages | ||
|
||
@pytest.fixture | ||
def temp_dir(): | ||
with tempfile.TemporaryDirectory() as temp_dir: | ||
yield pathlib.Path(temp_dir) | ||
|
||
|
||
def create_plugin(package_dir, plugin_name, setup): | ||
plugin_dir = package_dir / plugin_name | ||
plugin_dir.mkdir(parents=True) | ||
setup_py = plugin_dir / 'setup.py' | ||
setup_py.write_text(textwrap.dedent(setup)) | ||
return plugin_dir | ||
|
||
|
||
def test_install_local_package_with_dependency(temp_dir): | ||
packages_dir = temp_dir / 'packages' | ||
plugin_dir = create_plugin(packages_dir, 'dependency', setup=""" | ||
from setuptools import setup | ||
setup( | ||
name='dependency', | ||
install_requires=['fluentpy'] | ||
) | ||
""" | ||
) | ||
|
||
install_dir = temp_dir / 'target' | ||
install_dir.mkdir() | ||
|
||
packages.install_local_package(install_dir, plugin_dir) | ||
|
||
assert (install_dir / 'dependency.egg-link').is_file() | ||
assert (install_dir / 'fluentpy').is_dir() | ||
|
||
|
||
def test_install_local_package_with_dependency_and_extras_require(temp_dir): | ||
packages_dir = temp_dir / 'packages' | ||
plugin_dir = create_plugin(packages_dir, 'dependency', setup=""" | ||
from setuptools import setup | ||
setup( | ||
name='dependency', | ||
install_requires=['fluentpy'], | ||
extras_require={ | ||
'test': ['pyexpect'] | ||
} | ||
) | ||
""" | ||
) | ||
|
||
install_dir = temp_dir / 'target' | ||
install_dir.mkdir() | ||
|
||
packages.install_local_package(install_dir, plugin_dir) | ||
|
||
assert (install_dir / 'dependency.egg-link').is_file() | ||
assert (install_dir / 'fluentpy').is_dir() | ||
assert not (install_dir / 'pyexpect').is_dir() | ||
|
||
|
||
def test_install_local_package_with_only_extras_require(temp_dir): | ||
packages_dir = temp_dir / 'packages' | ||
plugin_dir = create_plugin(packages_dir, 'extras_require', setup=""" | ||
from setuptools import setup | ||
setup( | ||
name='extras_require', | ||
extras_require={ | ||
'test': ['pyexpect'] | ||
} | ||
) | ||
""" | ||
) | ||
|
||
install_dir = temp_dir / 'target' | ||
install_dir.mkdir() | ||
|
||
packages.install_local_package(install_dir, plugin_dir) | ||
|
||
assert (install_dir / 'extras-require.egg-link').is_file() | ||
assert not (install_dir / 'pyexpect').is_dir() |