Skip to content

1.0.1: pytest fails in tests/test_server.py::test_redirect_location_is_https_for_secure_server unitΒ #64

@kloczek

Description

@kloczek

I'm trying to package your module as an rpm package. So I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

  • python3 -sBm build -w
  • install .whl file in </install/prefix>
  • run pytest with PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>

Here is pytest output:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-httpbin-1.0.1-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-httpbin-1.0.1-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -p no:relaxed
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/pytest-httpbin-1.0.1
plugins: httpbin-1.0.1, forked-1.4.0, xdist-2.5.0
collected 20 items

tests/test_httpbin.py .............                                                                                                                                  [ 65%]
tests/test_server.py ......F                                                                                                                                         [100%]

================================================================================= FAILURES =================================================================================
____________________________________________________________ test_redirect_location_is_https_for_secure_server _____________________________________________________________

httpbin_secure = <pytest_httpbin.serve.SecureServer object at 0x7f352851acd0>

    def test_redirect_location_is_https_for_secure_server(httpbin_secure):
        assert httpbin_secure.url.startswith('https://')
        response = requests.get(
            httpbin_secure + "/redirect-to?url=/html",
            allow_redirects=False
        )
        assert response.status_code == 302
        assert response.headers.get('Location')
>       assert response.headers['Location'].startswith('https://')
E       AssertionError: assert False
E        +  where False = <built-in method startswith of str object at 0x7f3528501cf0>('https://')
E        +    where <built-in method startswith of str object at 0x7f3528501cf0> = '/html'.startswith

tests/test_server.py:105: AssertionError
--------------------------------------------------------------------------- Captured stderr call ---------------------------------------------------------------------------
127.0.0.1 - - [31/Dec/2021 05:00:36] "GET /redirect-to?url=/html HTTP/1.1" 302 0
========================================================================= short test summary info ==========================================================================
FAILED tests/test_server.py::test_redirect_location_is_https_for_secure_server - AssertionError: assert False
======================================================================= 1 failed, 19 passed in 2.56s =======================================================================

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions