neurodocker
neurodocker copied to clipboard
skip some tests when external dependency is not present
may be it was already implemented and intended, I am just presenting my observation:
$> python -m pytest -v -k "not test_build_image" neurodocker
================================================================= test session starts ==================================================================
platform linux -- Python 3.5.4, pytest-3.2.1, py-1.4.34, pluggy-0.4.0 -- /home/yoh/deb/perspect/neurodocker/venvs/dev/bin/python
cachedir: .cache
rootdir: /home/yoh/deb/perspect/neurodocker, inifile:
plugins: localserver-0.3.7, hypothesis-3.44.1
collected 66 items
neurodocker/docker/tests/test_docker.py::test_docker_is_running PASSED
neurodocker/docker/tests/test_docker.py::TestBuildOutputLogger::test_start PASSED
neurodocker/docker/tests/test_docker.py::TestBuildOutputLogger::test_get_logs PASSED
neurodocker/docker/tests/test_docker.py::TestDockerImage::test___init__ PASSED
neurodocker/docker/tests/test_docker.py::TestDockerImage::test_build PASSED
neurodocker/docker/tests/test_docker.py::TestDockerContainer::test_start_cleanup PASSED
neurodocker/docker/tests/test_docker.py::TestDockerContainer::test_exec_run PASSED
neurodocker/docker/tests/test_docker.py::TestDockerContainer::test_cleanup PASSED
neurodocker/docker/tests/test_docker.py::test_copy_file_from_container PASSED
neurodocker/docker/tests/test_docker.py::test_copy_file_to_container PASSED
neurodocker/interfaces/tests/test_afni.py::TestAFNI::test_invalid_binaries PASSED
neurodocker/interfaces/tests/test_ants.py::TestANTs::test_invalid_binaries PASSED
neurodocker/interfaces/tests/test_ants.py::TestANTs::test_build_from_source_github PASSED
neurodocker/interfaces/tests/test_freesurfer.py::TestFreeSurfer::test_copy_license PASSED
neurodocker/interfaces/tests/test_mrtrix.py::TestMRtrix3::test_build_from_source PASSED
neurodocker/reprozip/tests/test_merge.py::test_merge_pack_files FAILED
neurodocker/reprozip/tests/test_trace.py::test_ReproZipMinimizer_no_ptrace SKIPPED
neurodocker/reprozip/tests/test_trace.py::test_ReproZipMinimizer PASSED
neurodocker/tests/test_generate.py::test__add_add PASSED
neurodocker/tests/test_generate.py::test__add_to_entrypoint PASSED
neurodocker/tests/test_generate.py::test__add_arg PASSED
neurodocker/tests/test_generate.py::test__add_base PASSED
neurodocker/tests/test_generate.py::test__add_cmd PASSED
neurodocker/tests/test_generate.py::test__add_copy PASSED
neurodocker/tests/test_generate.py::test__add_entrypoint PASSED
neurodocker/tests/test_generate.py::test__add_env_vars FAILED
neurodocker/tests/test_generate.py::test__add_exposed_ports PASSED
neurodocker/tests/test_generate.py::test__add_install PASSED
neurodocker/tests/test_generate.py::test__add_arbitrary_instruction PASSED
neurodocker/tests/test_generate.py::test__add_label PASSED
neurodocker/tests/test_generate.py::test_add_run PASSED
neurodocker/tests/test_generate.py::test__add_run_bash PASSED
neurodocker/tests/test_generate.py::test__add_volume PASSED
neurodocker/tests/test_generate.py::test__add_workdir PASSED
neurodocker/tests/test_generate.py::test_DockerfileUsers PASSED
neurodocker/tests/test_generate.py::TestDockerfile::test___repr__ PASSED
neurodocker/tests/test_generate.py::TestDockerfile::test___str__ PASSED
neurodocker/tests/test_generate.py::TestDockerfile::test__create_cmd PASSED
neurodocker/tests/test_generate.py::TestDockerfile::test_save PASSED
neurodocker/tests/test_neurodocker.py::test_generate PASSED
neurodocker/tests/test_neurodocker.py::test_generate_opts FAILED
neurodocker/tests/test_neurodocker.py::test_generate_from_json PASSED
neurodocker/tests/test_neurodocker.py::test_generate_no_print PASSED
neurodocker/tests/test_neurodocker.py::test_generate_save PASSED
neurodocker/tests/test_parser.py::TestSpecsParser::test__validate_keys PASSED
neurodocker/tests/test_utils.py::test_manage_pkgs PASSED
neurodocker/tests/test_utils.py::test_check_url PASSED
neurodocker/tests/test_utils.py::test_indent PASSED
neurodocker/tests/test_utils.py::test_save_load_json PASSED
neurodocker/tests/test_utils.py::test_set_log_level PASSED
neurodocker/tests/test_version.py::test_get_gitversion PASSED
================================================== FAILURES ===================================================
____________________________________________ test_merge_pack_files ____________________________________________
def _check_deps():
"""Raise RuntimeError if a dependency is not found. These dependencies are
not included in `requirements.txt`.
"""
import shutil
msg = "Dependency '{}' not found."
if shutil.which('rsync') is None:
raise RuntimeError(msg.format('rsync'))
try:
> import reprozip
E ImportError: No module named 'reprozip'
neurodocker/reprozip/merge.py:47: ImportError
During handling of the above exception, another exception occurred:
def test_merge_pack_files():
tmpdir = tempfile.mkdtemp()
cmd = ["du -sh /usr", "rm --help"]
packpath = _create_packfile(cmd, tmpdir)
new_name = "first-pack.rpz"
os.rename(packpath, os.path.join(tmpdir, new_name))
cmd = ["ls -l /", "grep --help"]
_create_packfile(cmd, tmpdir)
pattern = os.path.join(tmpdir, '*.rpz')
packfiles = glob(pattern)
assert packfiles, "packfiles not found"
outfile = os.path.join(tmpdir, 'merged.rpz')
> merge_pack_files(outfile=outfile, packfiles=packfiles)
neurodocker/reprozip/tests/test_merge.py:48:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
neurodocker/reprozip/merge.py:165: in merge_pack_files
_check_deps()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def _check_deps():
"""Raise RuntimeError if a dependency is not found. These dependencies are
not included in `requirements.txt`.
"""
import shutil
msg = "Dependency '{}' not found."
if shutil.which('rsync') is None:
raise RuntimeError(msg.format('rsync'))
try:
import reprozip
except Exception:
> raise RuntimeError(msg.format('reprozip'))
E RuntimeError: Dependency 'reprozip' not found.
neurodocker/reprozip/merge.py:49: RuntimeError
_____________________________________________ test__add_env_vars ______________________________________________
def test__add_env_vars():
env = {'THIS': 'THAT'}
truth = 'ENV THIS="THAT"'
assert truth == DF._add_env_vars(env)
env['A'] = 'B'
truth = ('ENV THIS="THAT" \\\n A="B"')
> assert truth == DF._add_env_vars(env)
E assert 'ENV THIS="TH...\\\n A="B"' == 'ENV A="B" \\\n THIS="THAT"'
E - ENV THIS="THAT" \
E - A="B"
E + ENV A="B" \
E + THIS="THAT"
neurodocker/tests/test_generate.py:72: AssertionError
_____________________________________________ test_generate_opts ______________________________________________
capsys = <_pytest.capture.CaptureFixture object at 0x7fd553b11ba8>
def test_generate_opts(capsys):
args = "generate -b ubuntu:17.04 -p apt --no-check-urls {}"
main(args.format('--user=neuro').split())
out, _ = capsys.readouterr()
assert "USER neuro" in out
main(args.format('--add path/to/file.txt /tmp/file.txt').split())
out, _ = capsys.readouterr()
assert 'ADD ["path/to/file.txt", "/tmp/file.txt"]' in out
main(args.format('--copy path/to/file.txt /tmp/file.txt').split())
out, _ = capsys.readouterr()
assert 'COPY ["path/to/file.txt", "/tmp/file.txt"]' in out
main(args.format('--env KEY=VAL KEY2=VAL').split())
out, _ = capsys.readouterr()
> assert 'ENV KEY="VAL" \\' in out
E assert 'ENV KEY="VAL" \\' in '# Generated by Neurodocker v0.3.2-5-gf1376bf.\n#\n# Thank you for using Neurodocker. If you discover any issues\n# or...bf", \\\n \\n "generation_timestamp": "2018-01-12 10:42:29" \\\n \\n}\' > /neurodocker/neurodocker_specs.json\n'
neurodocker/tests/test_neurodocker.py:71: AssertionError
============================================= 15 tests deselected =============================================
======================= 3 failed, 47 passed, 1 skipped, 15 deselected in 236.14 seconds =======================
python -m pytest -v -k "not test_build_image" neurodocker 12.78s user 0.19s system 5% cpu 3:56.79 total
it is on a Debian system in a virtualenv with python 3.5
This is a great idea! Thanks @yarikoptic. I am in the process of refactoring this package to also generate Singularity definition files. That involves rewriting many of the tests, so I will be sure to implement this idea.
The refactoring is happening in the branch ref/to-yaml.
Ran into this as well. A fix would be appreciated. Let me know if you need help.
I will close this issue since it's pretty old and the test has been rewritten, please feel free to reopen if the problem still exists