repo2docker/tests/test_subdir.py

35 wiersze
948 B
Python
Czysty Zwykły widok Historia

2018-09-26 17:01:58 +00:00
"""
2018-09-27 16:07:27 +00:00
Test if the subdirectory is correctly navigated to
2018-09-26 17:01:58 +00:00
"""
import logging
from os.path import abspath, dirname
import pytest
from repo2docker.app import Repo2Docker
2018-10-15 17:59:16 +00:00
# This is the path to the repo2docker git repository that this file exists in.
2018-09-26 17:01:58 +00:00
repo_path = dirname(dirname(abspath(__file__)))
2018-09-26 22:33:52 +00:00
def test_subdir(run_repo2docker):
2018-09-26 17:01:58 +00:00
argv = ['--subdir', 'tests/conda/simple', repo_path]
2018-09-26 22:33:52 +00:00
run_repo2docker(argv)
2018-09-26 17:01:58 +00:00
def test_subdir_invalid(caplog):
caplog.set_level(logging.INFO, logger='Repo2Docker')
app = Repo2Docker()
argv = ['--subdir', 'tests/conda/invalid', repo_path]
app.initialize(argv)
app.debug = True
app.run = False
2018-10-15 17:58:00 +00:00
with pytest.raises(SystemExit) as excinfo:
2018-09-26 17:01:58 +00:00
app.start() # Just build the image and do not run it.
2018-10-15 17:58:00 +00:00
# The build should fail
assert excinfo.value.code == 1
2018-09-26 17:01:58 +00:00
# Can't get this to record the logs?
# assert caplog.text == "Subdirectory tests/conda/invalid does not exist"