From e9a92740a0931a31da0ed9dff374f9949ad55c72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20BREDIN?= Date: Thu, 22 Jun 2023 17:32:59 +0200 Subject: [PATCH] improve(test): use pyannote.database.registry (#1413) --- .github/workflows/test.yml | 1 - README.md | 5 ++--- tests/conftest.py | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 tests/conftest.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b266179e..df1182cf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,5 +29,4 @@ jobs: pip install -e .[dev,testing] - name: Test with pytest run: | - export PYANNOTE_DATABASE_CONFIG=$GITHUB_WORKSPACE/tests/data/database.yml pytest diff --git a/README.md b/README.md index c3f9a8dc..3bf1b2c8 100644 --- a/README.md +++ b/README.md @@ -126,9 +126,8 @@ pip install -e .[dev,testing] pre-commit install ``` -Tests rely on a set of debugging files available in [`test/data`](test/data) directory. -Set `PYANNOTE_DATABASE_CONFIG` environment variable to `test/data/database.yml` before running tests: +## Test ```bash -PYANNOTE_DATABASE_CONFIG=tests/data/database.yml pytest +pytest ``` diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 00000000..fe2a00e1 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,32 @@ +# MIT License +# +# Copyright (c) 2020- CNRS +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + + +def pytest_sessionstart(session): + """ + Called after the Session object has been created and + before performing collection and entering the run test loop. + """ + + from pyannote.database import registry + + registry.load_database("tests/data/database.yml")