From 9fb989d5c9803cbaed2d55ed4ba98e8d8517bb0c Mon Sep 17 00:00:00 2001 From: Adrien Barbaresi Date: Wed, 29 May 2024 17:54:29 +0200 Subject: [PATCH] maintenance: update setup and add tests (#150) * maintenance: update setup * adjust pytest paths * restore pytest.ini for now * add tests --- .github/FUNDING.yml | 12 ++++++++++++ MANIFEST.in | 2 +- setup.py | 4 ++-- tests/__init__.py | 8 -------- tests/eval-requirements.txt | 6 +++--- tests/unit_tests.py | 10 ++++++++++ 6 files changed, 28 insertions(+), 14 deletions(-) create mode 100644 .github/FUNDING.yml delete mode 100644 tests/__init__.py diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..08ccbf34 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: adbarbaresi +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # adbarbaresi +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/MANIFEST.in b/MANIFEST.in index beda1eab..ba264b6d 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,4 @@ -include README.rst LICENSE pytest.ini CHANGELOG.md CONTRIBUTING.md +include README.md CHANGELOG.md CONTRIBUTING.md LICENSE pyproject.toml include htmldate/py.typed include tests/unit_tests.py include tests/testlist.txt diff --git a/setup.py b/setup.py index 7c4c8dd3..c0e8d33d 100644 --- a/setup.py +++ b/setup.py @@ -120,8 +120,8 @@ def get_version(package): "charset_normalizer >= 3.3.2; python_version >= '3.7'", "dateparser >= 1.1.2", # 1.1.3+ slower # see tests on Github Actions - "lxml == 4.9.2; platform_system == 'Darwin' and python_version <= '3.8'", - "lxml >= 4.9.4, < 6; platform_system != 'Darwin' or python_version > '3.8'", + "lxml == 4.9.2 ; platform_system == 'Darwin' and python_version <= '3.8'", + "lxml >= 5.2.2, < 6 ; platform_system != 'Darwin' or python_version > '3.8'", "python-dateutil >= 2.8.2", "urllib3 >= 1.26, < 2; python_version < '3.7'", "urllib3 >= 1.26, < 3; python_version >= '3.7'", diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index 4071eb57..00000000 --- a/tests/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -# -*- coding: utf-8 -*- - -#from __future__ import (absolute_import, division, print_function, unicode_literals) - -#import os - -#import htmldate -import pytest # unittest? diff --git a/tests/eval-requirements.txt b/tests/eval-requirements.txt index 6ce9379f..c904a03b 100644 --- a/tests/eval-requirements.txt +++ b/tests/eval-requirements.txt @@ -1,12 +1,12 @@ # package -htmldate>=1.6.0 +htmldate>=1.8.1 # alternatives articleDateExtractor==0.20 date_guesser==2.1.4 -goose3==3.1.17 +goose3==3.1.19 newspaper3k==0.2.8 -news-please==1.5.35 +news-please==1.5.44 # helpers tabulate==0.9.0 diff --git a/tests/unit_tests.py b/tests/unit_tests.py index 2c41e746..1a72169a 100644 --- a/tests/unit_tests.py +++ b/tests/unit_tests.py @@ -107,6 +107,7 @@ def test_input(): assert load_html(123) is None assert "incompatible" in str(err.value) assert load_html("<" * 100) is None + assert load_html("ABC") is None assert load_html("XYZ") is not None assert load_html(b"XYZ") is not None assert load_html(b"<" * 100) is None @@ -1660,6 +1661,14 @@ def test_dependencies(): ) +def test_deferred(): + "Test deferred extraction" + htmlstring = '' + url = "https://example.org/2017/08/30/this.html" + assert find_date(htmlstring, url=url, deferred_url_extractor=True) == "2017-09-01" + assert find_date(htmlstring, url=url, deferred_url_extractor=False) == "2017-08-30" + + if __name__ == "__main__": # function-level test_input() @@ -1675,6 +1684,7 @@ def test_dependencies(): # test_header() # module-level + test_deferred() test_no_date() test_exact_date() test_search_html()