aboutsummaryrefslogtreecommitdiff
path: root/tests/testutils.py
blob: 3ddbdbed9cadd5dc6bb6c3862c8b03343ca67c90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"""Various utility functions for testing."""
import gzip
from pathlib import Path


def load_gpx_asset(filename):
    """Load a GPX test asset.

    This looks in the tests/assets/ folder, reads and unzips the file and
    returns its contents.

    :param filename: Name of the asset to load.
    :type filename: str
    :return: The content of the asset as bytes.
    :rtype: bytes
    """
    asset_dir = Path(__file__).parent / 'assets'
    test_file = asset_dir / filename
    with gzip.open(test_file, 'rb') as fobj:
        return fobj.read()