From 69c9167911a8449fef20951abe924a1c4528545c Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Sun, 17 Jul 2022 20:56:38 +0200 Subject: add tests for archive download --- tests/testutils.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/testutils.py (limited to 'tests/testutils.py') 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() -- cgit v1.2.3