1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
# -*- coding: utf-8 -*-
# Copyright 2007-2023 The HyperSpy developers
#
# This file is part of RosettaSciIO.
#
# RosettaSciIO is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# RosettaSciIO is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with RosettaSciIO. If not, see <https://www.gnu.org/licenses/#GPL>.
import os
from pathlib import Path
import pooch
from packaging.version import Version
import rsciio
version = rsciio.__version__
if Version(version).is_devrelease:
version = "main"
else:
version = f"v{version}"
TESTS_PATH = Path(__file__).parent
# This environment variable can be used to specify a base url other than the one
# from the hyperspy/rosettasciio repository.
# This is used in workflow when the test suite is run from the packages (test files
# not included), such as the "package and test" and "release" workflow on GitHub,
# other workflows use local files (available from the git repository)
BASE_URL = os.environ.get(
"POOCH_BASE_URL",
f"https://github.com/hyperspy/rosettasciio/raw/{version}/rsciio/tests/data/",
)
TEST_DATA_REGISTRY = pooch.create(
path=TESTS_PATH / "data",
base_url=BASE_URL,
# We don't use the version functionality of pooch because we want to use the
# local test folder (rsciio.tests.data)
version=None,
# We'll load it from a file later
registry=None,
allow_updates=False,
retry_if_failed=3,
)
TEST_DATA_REGISTRY.load_registry(TESTS_PATH / "registry.txt")
|