Add simple python test for --repo-path
extra-args.yaml placed in a test directory can be used
to pass extra arguments to the repo2docker command.
MODIFY
tests/conftest.py
tests/conftest.py
@@ -103,20 +103,26 @@ class Repo2DockerTest(pytest.Function):
class LocalRepo(pytest.File):
def collect(self):
- yield Repo2DockerTest(
- 'build', self,
args = [
'--appendix', 'RUN echo "appendix" > /tmp/appendix',
- self.fspath.dirname,
- ],
+ ]
+ # If there's an extra-args.yaml file in a test dir, assume it contains
+ # a yaml list with extra arguments to be passed to repo2docker
+ extra_args_path = os.path.join(self.fspath.dirname, 'extra-args.yaml')
+ if os.path.exists(extra_args_path):
+ with open(extra_args_path) as f:
+ extra_args = yaml.safe_load(f)
+ args += extra_args
+
+ args.append(self.fspath.dirname)
+
+ yield Repo2DockerTest(
+ 'build', self,
+ args=args
)
yield Repo2DockerTest(
self.fspath.basename, self,
- args=[
- '--appendix', 'RUN echo "appendix" > /tmp/appendix',
- self.fspath.dirname,
- './verify',
- ],
+ args=args + ['./verify']
)

ADD
tests/venv/repo-path/README.rst
+Python - Custom Repository Location
+-----------------------------------
+
+We want to support custom paths where repositories can be
+copied to, instead of ${HOME}. The `extra-args.yaml` file in
+each dir can contain a list of arguments that are passed
+to repo2docker during the test. We copy this repo to
+/srv/repo instead of ${HOME}
\ No newline at end of file

ADD
tests/venv/repo-path/extra-args.yaml
+- --repo-path
+- /srv/repo
\ No newline at end of file

ADD
tests/venv/repo-path/verify
+#!/usr/bin/env python
+import sys
+import os
+
+# Python should still be in /srv/conda
+assert sys.executable == '/srv/conda/bin/python'
+
+# Repo should be in /srv/repo
+assert os.path.exists('/srv/repo/verify')
+assert os.path.abspath(__file__) == '/srv/repo/verify'
\ No newline at end of file

Add simple python test for --repo-path

extra-args.yaml placed in a test directory can be used
to pass extra arguments to the repo2docker command.