twisted / treq

Python requests like API built on top of Twisted's HTTP client.
Other
585 stars 137 forks source link

test_request_uri_plus_pass test fails #345

Closed ryandesign closed 2 years ago

ryandesign commented 2 years ago

The test_request_uri_plus_pass test fails. I tested treq 22.2.0 with Python 3.10.2 as installed by MacPorts on macOS 10.15.7.

    test_request_uri_plus_pass ...                                      [ERROR]
===============================================================================
[ERROR]
Traceback (most recent call last):
  File "/path/to/treq-22.2.0/build/lib/treq/test/test_client.py", line 112, in test_request_uri_plus_pass
    self.agent.request.assert_called_once_with(
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/unittest/mock.py", line 931, in assert_called_once_with
    return self.assert_called_with(*args, **kwargs)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/unittest/mock.py", line 919, in assert_called_with
    raise AssertionError(_error_message()) from cause
builtins.AssertionError: expected call not found.
Expected: request(b'GET', b'https://example.com/?foo+bar=baz+biff', Headers({b'accept-encoding': [b'gzip']}), None)
Actual: request(b'GET', b'https://example.com/?foo%2Bbar=baz%2Bbiff', Headers({b'accept-encoding': [b'gzip']}), None)

treq.test.test_client.HTTPClientTests.test_request_uri_plus_pass
-------------------------------------------------------------------------------
Ran 227 tests in 46.644s

FAILED (errors=1, successes=226)
twm commented 2 years ago

Hi @ryandesign, Python 3.10 is part of our test matrix so I think it's unlikely that's the issue here. Given URL escaping is the issue what version of Hyperlink is installed? This smells like https://github.com/python-hyper/hyperlink/pull/146

ryandesign commented 2 years ago

Thanks. Hyperlink 19.0.0 was installed. I see that issue the was fixed in Hyperlink 21.0.0. I'll advise the MacPorts maintainer of Hyperlink to update it.

twm commented 2 years ago

It sounds like there is something wrong with the translation of Treq's requirements, then. Treq requires a sufficiently new version of Hyperlink. I'm not familiar with Macports, but in something like Debian this would be represented in the package.

ryandesign commented 2 years ago

MacPorts does not offer multiple different versions of Python modules, nor of any port, nor, therefore, does MacPorts have the capability of specifying a dependency on a specific version of another port. One only specifies a dependency on another port, and MacPorts ensures that it is upgraded to the latest version available in MacPorts first.

I am not very familiar with how Python works so I cannot say whether or how the module versioning requirements specified in the treq setup.py would be checked; I can only observe that no such checking appears to be taking place.