Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting warnings while testing extract() function with with pytest #320

Closed
sdondley opened this issue Apr 9, 2023 · 0 comments · Fixed by #321
Closed

Getting warnings while testing extract() function with with pytest #320

sdondley opened this issue Apr 9, 2023 · 0 comments · Fixed by #321

Comments

@sdondley
Copy link
Contributor

sdondley commented Apr 9, 2023

I have this code:

from trafilatura import extract
import json
from get_html_from_safari.get_html_from_safari import get_html

def get_article_data(url=None):
    if url is None:
        html = get_html()
    else:
        html = get_html(url)

    data_str = extract(html)

I have this test:

from nlp_extractor_simple.nlp_extractor_simple import get_article_data

def test_get_article():
    get_article_data();

When running the test, I get warnings in the pytest output:

tests/test_01-basic.py::test_get_article
  /usr/local/lib/python3.11/site-packages/trafilatura/core.py:560: DeprecationWarning: NotImplemented should not be used in a boolean context
    result_body.extend(filter(None.__ne__, (handle_textelem(e, potential_tags, options) for e in subelems)))

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
sdondley added a commit to sdondley/trafilatura that referenced this issue Apr 9, 2023
@adbar adbar linked a pull request Apr 11, 2023 that will close this issue
adbar added a commit that referenced this issue Apr 11, 2023
* #320 - update deprecated code

* filter: use lambda function in other similar cases

---------

Co-authored-by: Adrien Barbaresi <barbaresi@bbaw.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant