diff options
author | Daniel Schadt <kingdread@gmx.de> | 2022-07-17 20:56:38 +0200 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2022-07-17 20:56:38 +0200 |
commit | 69c9167911a8449fef20951abe924a1c4528545c (patch) | |
tree | 95b840058d8abf78e7b0fdd0331a0b86fef7b6d3 /tests/testutils.py | |
parent | d8ba9371656f9bd1492b9fbe13234f216ebbd240 (diff) | |
download | fietsboek-69c9167911a8449fef20951abe924a1c4528545c.tar.gz fietsboek-69c9167911a8449fef20951abe924a1c4528545c.tar.bz2 fietsboek-69c9167911a8449fef20951abe924a1c4528545c.zip |
add tests for archive download
Diffstat (limited to 'tests/testutils.py')
-rw-r--r-- | tests/testutils.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/testutils.py b/tests/testutils.py new file mode 100644 index 0000000..3ddbdbe --- /dev/null +++ b/tests/testutils.py @@ -0,0 +1,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() |