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

Running pytest sometimes fails #19

Open
jonasfreimuth opened this issue Oct 10, 2023 · 1 comment
Open

Running pytest sometimes fails #19

jonasfreimuth opened this issue Oct 10, 2023 · 1 comment

Comments

@jonasfreimuth
Copy link
Contributor

Running pytest (in a venv) on commit 6cd14fb sometimes fails with the following error:

(.venv) jfreige@sl-akali-p-cs1:easy-entrez (main)$ pytest
=================================================================== test session starts ====================================================================
platform linux -- Python 3.10.12, pytest-7.4.2, pluggy-1.3.0
rootdir: /data/local/jfreige/geo-mining/easy-entrez
plugins: cov-4.1.0
collected 15 items

tests/test_api.py .F.                                                                                                                                [ 20%]
tests/test_parsing.py ....                                                                                                                           [ 46%]
tests/test_queries.py ........                                                                                                                       [100%]

========================================================================= FAILURES =========================================================================
_______________________________________________________________________ test_search ________________________________________________________________________

    def test_search():
        result = entrez_api.search('cancer AND human[organism]', max_results=1)
        assert is_response_for(result, SearchQuery)
        assert not is_response_for(result, FetchQuery)
>       assert result.data['esearchresult']['count'] != 0

tests/test_api.py:29:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
easy_entrez/api.py:45: in data
    if self.content_type == 'json':
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <EntrezResponse status=502 for SearchQuery 'cancer AND human[organism]' in pubmed>

    @property
    def content_type(self) -> ReturnType:
        declared_type = self.response.headers['Content-Type']
        if declared_type.startswith('application/json'):
            return 'json'
        if declared_type.startswith('text/xml'):
            return 'xml'
>       raise ValueError(f'Unknown content type: {declared_type}')
E       ValueError: Unknown content type: text/plain

easy_entrez/api.py:41: ValueError
===================================================================== warnings summary =====================================================================
tests/test_parsing.py:39
  /data/local/jfreige/geo-mining/easy-entrez/tests/test_parsing.py:39: PytestUnknownMarkWarning: Unknown pytest.mark.optional - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
    @pytest.mark.optional

tests/test_parsing.py:78
  /data/local/jfreige/geo-mining/easy-entrez/tests/test_parsing.py:78: PytestUnknownMarkWarning: Unknown pytest.mark.optional - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
    @pytest.mark.optional

tests/test_parsing.py:89
  /data/local/jfreige/geo-mining/easy-entrez/tests/test_parsing.py:89: PytestUnknownMarkWarning: Unknown pytest.mark.optional - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
    @pytest.mark.optional

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================= short test summary info ==================================================================
FAILED tests/test_api.py::test_search - ValueError: Unknown content type: text/plain
======================================================== 1 failed, 14 passed, 3 warnings in 13.15s =========================================================```
@jonasfreimuth
Copy link
Contributor Author

Ok great, after some time I also got this one on main, I will reopen #18:

=================================================================================== test session starts ====================================================================================
platform linux -- Python 3.10.12, pytest-7.4.2, pluggy-1.3.0
rootdir: /data/local/jfreige/geo-mining/easy-entrez
plugins: cov-4.1.0
collected 15 items

tests/test_api.py ..F                                                                                                                                                                [ 20%]
tests/test_parsing.py ....                                                                                                                                                           [ 46%]
tests/test_queries.py ........                                                                                                                                                       [100%]

========================================================================================= FAILURES =========================================================================================
________________________________________________________________________________________ test_fetch ________________________________________________________________________________________

    def test_fetch():
        result = entrez_api.fetch(['4'], max_results=1, database='snp')
        assert is_response_for(result, FetchQuery)
        assert not is_response_for(result, SearchQuery)
        snp = result.data[0]
        namespaces = {'ns0': 'https://www.ncbi.nlm.nih.gov/SNP/docsum'}
>       chromosome = snp.find('.//ns0:CHR', namespaces).text
E       AttributeError: 'NoneType' object has no attribute 'text'

tests/test_api.py:38: AttributeError
===================================================================================== warnings summary =====================================================================================
tests/test_parsing.py:39
  /data/local/jfreige/geo-mining/easy-entrez/tests/test_parsing.py:39: PytestUnknownMarkWarning: Unknown pytest.mark.optional - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
    @pytest.mark.optional

tests/test_parsing.py:78
  /data/local/jfreige/geo-mining/easy-entrez/tests/test_parsing.py:78: PytestUnknownMarkWarning: Unknown pytest.mark.optional - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
    @pytest.mark.optional

tests/test_parsing.py:89
  /data/local/jfreige/geo-mining/easy-entrez/tests/test_parsing.py:89: PytestUnknownMarkWarning: Unknown pytest.mark.optional - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
    @pytest.mark.optional

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================================= short test summary info ==================================================================================
FAILED tests/test_api.py::test_fetch - AttributeError: 'NoneType' object has no attribute 'text'
======================================================================== 1 failed, 14 passed, 3 warnings in 13.46s =========================================================================

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

No branches or pull requests

1 participant