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

1.4.1: pytest is failing in test/test_get_filelike.py::test_get_filelike unit #62

Open
kloczek opened this issue Aug 16, 2023 · 1 comment

Comments

@kloczek
Copy link

kloczek commented Aug 16, 2023

Looks like URL used in test suite fails in test/test_get_filelike.py::test_get_filelike unit

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-imagesize-1.4.1-5.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-imagesize-1.4.1-5.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network'
============================= test session starts ==============================
platform linux -- Python 3.8.17, pytest-7.4.0, pluggy-1.2.0
rootdir: /home/tkloczko/rpmbuild/BUILD/imagesize_py-1.4.1
collected 45 items

test/test_get.py .......................                                 [ 51%]
test/test_get_filelike.py F                                              [ 53%]
test/test_getdpi.py .....................                                [100%]

=================================== FAILURES ===================================
______________________________ test_get_filelike _______________________________

    def test_get_filelike():
        """ test_get_filelike. """

        url = 'https://www.tsln.com/wp-content/uploads/2018/10/bears-tsln-101318-3-1240x826.jpg'
        try:
>           response = urlopen(url)

test/test_get_filelike.py:28:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib64/python3.8/urllib/request.py:222: in urlopen
    return opener.open(url, data, timeout)
/usr/lib64/python3.8/urllib/request.py:531: in open
    response = meth(req, response)
/usr/lib64/python3.8/urllib/request.py:640: in http_response
    response = self.parent.error(
/usr/lib64/python3.8/urllib/request.py:569: in error
    return self._call_chain(*args)
/usr/lib64/python3.8/urllib/request.py:502: in _call_chain
    result = func(*args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <urllib.request.HTTPDefaultErrorHandler object at 0x7f3467737cd0>
req = <urllib.request.Request object at 0x7f34677378b0>
fp = <http.client.HTTPResponse object at 0x7f34677f60d0>, code = 404
msg = 'Not Found', hdrs = <http.client.HTTPMessage object at 0x7f34676b1760>

    def http_error_default(self, req, fp, code, msg, hdrs):
>       raise HTTPError(req.full_url, code, msg, hdrs, fp)
E       urllib.error.HTTPError: HTTP Error 404: Not Found

/usr/lib64/python3.8/urllib/request.py:649: HTTPError

During handling of the above exception, another exception occurred:

    def test_get_filelike():
        """ test_get_filelike. """

        url = 'https://www.tsln.com/wp-content/uploads/2018/10/bears-tsln-101318-3-1240x826.jpg'
        try:
            response = urlopen(url)
            raw = response.read()
        except Exception as exc:
>           raise SystemExit(exc)
E           SystemExit: HTTP Error 404: Not Found

test/test_get_filelike.py:31: SystemExit
=========================== short test summary info ============================
FAILED test/test_get_filelike.py::test_get_filelike - SystemExit: HTTP Error ...
========================= 1 failed, 44 passed in 1.40s =========================

Other thing is that all units which needs more than localhost would be good to marked by network pytest mark which is used widely many other modules test suites.
https://docs.pytest.org/en/7.1.x/example/markers.html
Many distributions build envs are intentionally cut off from access to public network and running in such conditions pytest -m "not network" would allows easy skip such units.

@kloczek
Copy link
Author

kloczek commented Mar 7, 2024

gentle ping .. any update? 🤔

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