-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a stub CondaPackage for use with tests.
For all tests except test_tools, stub out the CondaPackage class using a globally autoused conftest fixture. This CondaPackage doesn't do anything and simply assumes that the packages are installed. This is useful because simple commands like "conda list" take considerable amounts of time. The conda commands are still tested in test_tools, which overrides the stub_conda fixture with a local one.
- Loading branch information
Showing
3 changed files
with
100 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,79 @@ | ||
import logging | ||
import os | ||
import pytest | ||
import tools | ||
|
||
|
||
class StubCondaPackage(tools.Tool): | ||
|
||
# Skip gathering in all_tool_classes | ||
_skiptest = True | ||
|
||
def __init__( | ||
self, | ||
package, | ||
channel="bioconda", | ||
executable=None, | ||
version="", | ||
verifycmd=None, | ||
verifycode=0, | ||
require_executability=True, | ||
env=None, | ||
env_root_path=None, | ||
conda_cache_path=None, | ||
patches=None, | ||
post_install_command=None, | ||
post_install_ret=0, | ||
post_verify_command=None, | ||
post_verify_ret=0 | ||
): | ||
self.executable = executable or package | ||
if type(version) == tools.CondaPackageVersion: | ||
self.version = version | ||
else: | ||
self.version = tools.CondaPackageVersion(version) | ||
|
||
self.env_path = None | ||
if 'CONDA_PREFIX' in os.environ and len(os.environ['CONDA_PREFIX']): | ||
last_path_component = os.path.basename(os.path.normpath(os.environ['CONDA_PREFIX'])) | ||
self.env_path = os.path.dirname(os.environ['CONDA_PREFIX']) if last_path_component == "bin" else os.environ['CONDA_PREFIX'] | ||
|
||
else: | ||
raise Exception | ||
|
||
def is_attempted(self): | ||
return True | ||
|
||
def is_installed(self): | ||
return True | ||
|
||
@property | ||
def bin_path(self): | ||
return os.path.join(self.env_path, 'bin') | ||
|
||
def executable_path(self): | ||
return os.path.join(self.bin_path, self.executable) | ||
|
||
def apply_patches(self): | ||
pass | ||
|
||
def verify_install(self): | ||
return | ||
|
||
def package_available(self): | ||
return True | ||
|
||
def uninstall_package(self): | ||
return True | ||
|
||
def install_package(self): | ||
return True | ||
|
||
def get_installed_version(self): | ||
return self.version | ||
|
||
def post_install(self): | ||
pass | ||
|
||
def execute(self, cmd, loglevel=logging.DEBUG): | ||
return {} |
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 |
---|---|---|
|
@@ -2,15 +2,20 @@ | |
|
||
__author__ = "[email protected]" | ||
|
||
import pytest | ||
import tools | ||
from tools import * | ||
import pytest | ||
|
||
# Simply do nothing to override stub_conda in conftest.py | ||
@pytest.fixture(autouse=True) | ||
def stub_conda(): | ||
pass | ||
|
||
@pytest.fixture(params=tools.all_tool_classes()) | ||
def tool_class(request): | ||
print(request.param) | ||
return request.param | ||
|
||
@pytest.mark.slow | ||
def test_tool_install(tool_class): | ||
t = tool_class() | ||
t.install() | ||
|