From 995ab9548be14557ae0283d9b956b00caab10639 Mon Sep 17 00:00:00 2001 From: benoit74 Date: Tue, 26 Nov 2024 12:54:39 +0000 Subject: [PATCH] Expose to have access to zimscraperlib version from scrapers --- CHANGELOG.md | 1 + src/zimscraperlib/constants.py | 1 + tests/test_constants.py | 13 +++++++++++++ 3 files changed, 15 insertions(+) create mode 100644 tests/test_constants.py diff --git a/CHANGELOG.md b/CHANGELOG.md index add4565..f57d942 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Add `filesystem.validate_folder_writable` to check if a folder can be written to #200 +- Expose `constants.VERSION` to have access to zimscraperlib version from scrapers #224 ### Fixed diff --git a/src/zimscraperlib/constants.py b/src/zimscraperlib/constants.py index 0011edb..4e60112 100644 --- a/src/zimscraperlib/constants.py +++ b/src/zimscraperlib/constants.py @@ -10,6 +10,7 @@ ROOT_DIR = pathlib.Path(__file__).parent NAME = pathlib.Path(__file__).parent.name SCRAPER = f"{NAME} {__version__}" +VERSION = __version__ CONTACT = "dev@openzim.org" DEFAULT_USER_AGENT = f"{NAME}/{__version__} ({CONTACT})" diff --git a/tests/test_constants.py b/tests/test_constants.py new file mode 100644 index 0000000..17ff0dc --- /dev/null +++ b/tests/test_constants.py @@ -0,0 +1,13 @@ +from zimscraperlib import constants + + +def test_name(): + assert constants.NAME + + +def test_scraper(): + assert constants.SCRAPER + + +def test_version(): + assert constants.VERSION