Skip to content

Commit d0ca3a2

Browse files
committed
DOC + Adding config argument in narps_open_tester
1 parent 928019d commit d0ca3a2

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

docs/testing.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Tests can be launched manually or while using CI (Continuous Integration).
4242
* To specify a test -for which the name contains 'test_pattern'- inside a test file : `pytest test_file.py -k "test_pattern"`
4343
* To run a tests with a given mark 'mark' : `pytest -m 'mark'`
4444
* To create code coverage data : `coverage run -m pytest ./tests` then `coverage report` to see the code coverage result or `coverage xml` to output a .xml report file
45+
* To use a custom configuration file (other than `narps_open/utils/configuration/test_config.toml` that is used by default): `pytest --narps_open_config=<path_to_the_custom_config_file>`
4546

4647
## Command line tools
4748

@@ -62,6 +63,7 @@ The command line tool `narps_open_correlations` is also available and can be use
6263

6364
```bash
6465
narps_open_correlations -t 2T6S -n 60
66+
narps_open_correlations -t 2T6S -n 60 --config <path_to_a_custom_config_file>
6567
```
6668

6769
to get the correlation values for the results of a previously executed pipeline (here team 2T6S, with 60 subjects).
@@ -70,7 +72,7 @@ to get the correlation values for the results of a previously executed pipeline
7072

7173
* `pytest.ini` is a global configuration files for using pytest (see reference [here](https://docs.pytest.org/en/7.1.x/reference/customize.html)). It allows to [register markers](https://docs.pytest.org/en/7.1.x/example/markers.html) that help to better identify tests. Note that `pytest.ini` could be replaced by data inside `pyproject.toml` in the next versions.
7274
* `tests/conftest.py` defines common functions, parameters, and [helpers](https://pytest-helpers-namespace.readthedocs.io/en/latest/) that are later available to all tests
73-
* `narps_open/utils/configuration/testing_config.toml` sets the parameters for the `testing` configuration type (see how the [configuration](/docs/configuration.md) module works). This configuration type is automatically used for testing (as defined in `tests/conftest.py`).
75+
* `narps_open/utils/configuration/testing_config.toml` sets the parameters for the `testing` configuration type (see how the [configuration](/docs/configuration.md) module works). This configuration type is used by default for testing (as defined in `tests/conftest.py`), but a configuration can be passed at runtime using the `narps_open_config` option in the `pytest` command line.
7476

7577
## Writing tests
7678

narps_open/tester.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,22 @@ def main():
1717
parser = ArgumentParser(description='Test the pipelines from NARPS.')
1818
parser.add_argument('-t', '--team', type=str, required=True,
1919
help='the team ID', choices=get_implemented_pipelines())
20+
parser.add_argument('--config', type=str, required=False,
21+
help='custom configuration file to be used')
2022
arguments = parser.parse_args()
2123

22-
sys.exit(pytest.main([
24+
pytest_arguments = [
2325
'-s',
2426
'-q',
2527
'-x',
2628
f'tests/pipelines/test_team_{arguments.team}.py',
2729
'-m',
28-
'pipeline_test']))
30+
'pipeline_test']
31+
32+
if 'config' in arguments:
33+
pytest_arguments.append(f'--narps_open_config={arguments.config}')
34+
35+
sys.exit(pytest.main(pytest_arguments))
2936

3037
if __name__ == '__main__':
3138
main()

0 commit comments

Comments
 (0)