-
-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: private tlds can be used at call-time
- Adds `include_psl_private_domains` to the `__call__` method. This is now something you can choose on a per-call basis. The object level argument now is only a default value for each call. - The entire dataset from publicsuffix.org is saved to cache - Ensured no weird cache issues happen when using with different `suffix_list_urls` by using different filenames per `suffix_list_urls` - Use filelock to support multiprocessing and multithreading use cases - Updates the bundled snapshot to be the raw publicsuffix data. Need to look at performance impact of this. - various other cleanups
- Loading branch information
1 parent
1dd19cf
commit 8b9bcc3
Showing
14 changed files
with
13,737 additions
and
7,484 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,12 @@ | ||
'''tldextract integration tests.''' | ||
|
||
import logging | ||
import os | ||
import traceback | ||
|
||
import pytest | ||
|
||
import tldextract | ||
|
||
|
||
def test_log_snapshot_diff(mocker): | ||
mocker.patch.object(logging.getLogger(), 'level', logging.DEBUG) | ||
debug_mock = mocker.patch.object(logging.getLogger('tldextract'), 'debug') | ||
|
||
extractor = tldextract.TLDExtract() | ||
try: | ||
os.remove(extractor.cache_file) | ||
except (IOError, OSError): | ||
logging.warning(traceback.format_exc()) | ||
|
||
extractor('ignore.com') | ||
|
||
assert debug_mock.call_count == 1 | ||
log_str = debug_mock.call_args[0][0] | ||
assert log_str.startswith('computed TLD diff') | ||
|
||
|
||
def test_bad_kwargs(): | ||
with pytest.raises(ValueError): | ||
tldextract.TLDExtract( | ||
cache_file=False, suffix_list_urls=False, fallback_to_snapshot=False | ||
cache_dir=False, suffix_list_urls=False, fallback_to_snapshot=False | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"""Test the caching functionality""" | ||
import pytest | ||
|
||
from tldextract.cache import DiskCache | ||
|
||
|
||
def test_disk_cache(tmpdir): | ||
cache = DiskCache(tmpdir) | ||
cache.set("testing", "foo", "bar") | ||
assert cache.get("testing", "foo") == "bar" | ||
|
||
cache.clear() | ||
|
||
with pytest.raises(KeyError): | ||
cache.get("testing", "foo") | ||
|
||
cache.set("testing", "foo", "baz") | ||
assert cache.get("testing", "foo") == "baz" |
Oops, something went wrong.