Skip to content

Commit

Permalink
maintenance: update setup and add tests (#150)
Browse files Browse the repository at this point in the history
* maintenance: update setup

* adjust pytest paths

* restore pytest.ini for now

* add tests
  • Loading branch information
adbar committed May 29, 2024
1 parent f33c1d9 commit 9fb989d
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 14 deletions.
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -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']
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'",
Expand Down
8 changes: 0 additions & 8 deletions tests/__init__.py

This file was deleted.

6 changes: 3 additions & 3 deletions tests/eval-requirements.txt
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions tests/unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("<xml><body>ABC</body></xml>") is None
assert load_html("<html><body>XYZ</body></html>") is not None
assert load_html(b"<html><body>XYZ</body></html>") is not None
assert load_html(b"<" * 100) is None
Expand Down Expand Up @@ -1660,6 +1661,14 @@ def test_dependencies():
)


def test_deferred():
"Test deferred extraction"
htmlstring = '<html><head><meta property="og:published_time" content="2017-09-01"/></head><body></body></html>'
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()
Expand All @@ -1675,6 +1684,7 @@ def test_dependencies():
# test_header()

# module-level
test_deferred()
test_no_date()
test_exact_date()
test_search_html()
Expand Down

0 comments on commit 9fb989d

Please sign in to comment.