Skip to content

1.1.4: pytest is failing because missing context and port fixtures and some pytest warnings #449

@kloczek

Description

@kloczek

pytest is for me and to be honest I know that something is missing in my build env but I cannot figure out which one module(s) I need to install :/
May I as for some hints?
And in below output latest pytest (6.2.4) shows some deprecation warnings

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-httpretty-1.1.4-3.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-httpretty-1.1.4-3.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
=========================================================================== 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/HTTPretty-1.1.4
plugins: anyio-3.3.4, cov-3.0.0
collected 11154 items

tests/bugfixes/nosetests/test_242_ssl_bad_handshake.py .                                                                                                             [  0%]
tests/bugfixes/nosetests/test_387_regex_port.py ..                                                                                                                   [  0%]
tests/bugfixes/nosetests/test_388_unmocked_error_with_url.py .                                                                                                       [  0%]
tests/bugfixes/nosetests/test_413_regex.py ..                                                                                                                        [  0%]
tests/bugfixes/nosetests/test_414_httpx.py .                                                                                                                         [  0%]
tests/bugfixes/nosetests/test_416_boto3.py .                                                                                                                         [  0%]
tests/bugfixes/nosetests/test_417_openssl.py ..                                                                                                                      [  0%]
tests/bugfixes/nosetests/test_425_latest_requests.py .                                                                                                               [  0%]
tests/bugfixes/nosetests/test_430_respect_timeout.py .                                                                                                               [  0%]
tests/bugfixes/nosetests/test_eventlet.py .                                                                                                                          [  0%]
tests/bugfixes/nosetests/test_redis.py s                                                                                                                             [  0%]
tests/bugfixes/nosetests/test_tornado_bind_unused_port.py s                                                                                                          [  0%]
tests/bugfixes/pytest/test_426_mypy_segfault.py .................................................................................................................... [  1%]
.................................................................................................................................................................... [  2%]
.................................................................................................................................................................... [  4%]
.................................................................................................................................................................... [  5%]
.................................................................................................................................................................... [  7%]
.................................................................................................................................................................... [  8%]
.................................................................................................................................................................... [  9%]
.................................................................................................................................................................... [ 11%]
.................................................................................................................................................................... [ 12%]
.................................................................................................................................................................... [ 14%]
.................................................................................................................................................................... [ 15%]
.................................................................................................................................................................... [ 17%]
.................................................................................................................................................................... [ 18%]
.................................................................................................................................................................... [ 20%]
.................................................................................................................................................................... [ 21%]
.................................................................................................................................................................... [ 23%]
.................................................................................................................................................................... [ 24%]
.................................................................................................................................................................... [ 26%]
.................................................................................................................................................................... [ 27%]
.................................................................................................................................................................... [ 29%]
.................................................................................................................................................................... [ 30%]
.................................................................................................................................................................... [ 32%]
.................................................................................................................................................................... [ 33%]
.................................................................................................................................................................... [ 34%]
.................................................................................................................................................................... [ 36%]
.................................................................................................................................................................... [ 37%]
.................................................................................................................................................................... [ 39%]
.................................................................................................................................................................... [ 40%]
.................................................................................................................................................................... [ 42%]
.................................................................................................................................................................... [ 43%]
.................................................................................................................................................................... [ 45%]
.................................................................................................................................................................... [ 46%]
.................................................................................................................................................................... [ 48%]
.................................................................................................................................................................... [ 49%]
.................................................................................................................................................................... [ 51%]
.................................................................................................................................................................... [ 52%]
.................................................................................................................................................................... [ 54%]
.................................................................................................................................................................... [ 55%]
.................................................................................................................................................................... [ 57%]
.................................................................................................................................................................... [ 58%]
.................................................................................................................................................................... [ 59%]
.................................................................................................................................................................... [ 61%]
.................................................................................................................................................................... [ 62%]
.................................................................................................................................................................... [ 64%]
.................................................................................................................................................................... [ 65%]
.................................................................................................................................................................... [ 67%]
.................................................................................................................................................................... [ 68%]
.................................................................................................................................................................... [ 70%]
.................................................................................................................................................................... [ 71%]
.................................................................................................................................................................... [ 73%]
.................................................................................................................................................................... [ 74%]
.................................................................................................................................................................... [ 76%]
.................................................................................................................................................................... [ 77%]
.................................................................................................................................................................... [ 79%]
.................................................................................................................................................................... [ 80%]
.................................................................................................................................................................... [ 82%]
.................................................................................................................................................................... [ 83%]
.................................................................................................................................................................... [ 84%]
.................................................................................................................................................................... [ 86%]
.................................................................................................................................................................... [ 87%]
.................................................................................................................................................................... [ 89%]
.................................................................................................................................................................... [ 90%]
.................................................................................................................................................................... [ 92%]
.................................................................................................................................................................... [ 93%]
.................................................................................................................................................................... [ 95%]
.................................................................................................................................................................... [ 96%]
.................................................................................................................................................................... [ 98%]
............................................................                                                                                                         [ 98%]
tests/functional/test_bypass.py EEEE..                                                                                                                               [ 98%]
tests/functional/test_debug.py EEEEE                                                                                                                                 [ 98%]
tests/functional/test_decorator.py ......                                                                                                                            [ 98%]
tests/functional/test_httplib2.py .......F....                                                                                                                       [ 99%]
tests/functional/test_passthrough.py ..                                                                                                                              [ 99%]
tests/functional/test_requests.py .................E..................                                                                                               [ 99%]
tests/functional/test_urllib2.py .......F....                                                                                                                        [ 99%]
tests/pyopenssl/test_mock.py .                                                                                                                                       [ 99%]
tests/unit/test_core.py ..........................                                                                                                                   [ 99%]
tests/unit/test_http.py .                                                                                                                                            [ 99%]
tests/unit/test_httpretty.py .............................                                                                                                           [ 99%]
tests/unit/test_main.py ...                                                                                                                                          [100%]

================================================================================== ERRORS ==================================================================================
_________________________________________________________ ERROR at setup of test_httpretty_bypasses_when_disabled __________________________________________________________
file /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/tests/functional/test_bypass.py, line 89
  @httpretty.activate
  @that_with_context(start_http_server, stop_http_server)
  def test_httpretty_bypasses_when_disabled(context):
E       fixture 'context' not found
>       available fixtures: anyio_backend, anyio_backend_name, anyio_backend_options, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, cov, doctest_namespace, monkeypatch, no_cover, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/tests/functional/test_bypass.py:89
_____________________________________________________ ERROR at setup of test_httpretty_bypasses_a_unregistered_request _____________________________________________________
file /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/tests/functional/test_bypass.py, line 123
  @httpretty.activate(verbose=True)
  @that_with_context(start_http_server, stop_http_server)
  def test_httpretty_bypasses_a_unregistered_request(context):
E       fixture 'context' not found
>       available fixtures: anyio_backend, anyio_backend_name, anyio_backend_options, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, cov, doctest_namespace, monkeypatch, no_cover, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/tests/functional/test_bypass.py:123
_____________________________________________________ ERROR at setup of test_using_httpretty_with_other_tcp_protocols ______________________________________________________
file /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/tests/functional/test_bypass.py, line 146
  @httpretty.activate(verbose=True)
  @that_with_context(start_tcp_server, stop_tcp_server)
  def test_using_httpretty_with_other_tcp_protocols(context):
E       fixture 'context' not found
>       available fixtures: anyio_backend, anyio_backend_name, anyio_backend_options, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, cov, doctest_namespace, monkeypatch, no_cover, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/tests/functional/test_bypass.py:146
______________________________________________________________ ERROR at setup of test_disallow_net_connect_1 _______________________________________________________________
file /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/tests/functional/test_bypass.py, line 164
  @httpretty.activate(allow_net_connect=False)
  @that_with_context(start_http_server, stop_http_server)
  def test_disallow_net_connect_1(context, verbose=True):
E       fixture 'context' not found
>       available fixtures: anyio_backend, anyio_backend_name, anyio_backend_options, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, cov, doctest_namespace, monkeypatch, no_cover, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/tests/functional/test_bypass.py:164
___________________________________________________________ ERROR at setup of test_httpretty_debugs_socket_send ____________________________________________________________
file /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/tests/functional/test_debug.py, line 39
  @skip('not currently supported')
  @httprettified
  @scenario(create_socket)
  def test_httpretty_debugs_socket_send(context):
E       fixture 'context' not found
>       available fixtures: anyio_backend, anyio_backend_name, anyio_backend_options, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, cov, doctest_namespace, monkeypatch, no_cover, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/tests/functional/test_debug.py:39
__________________________________________________________ ERROR at setup of test_httpretty_debugs_socket_sendto ___________________________________________________________
file /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/tests/functional/test_debug.py, line 50
  @skip('not currently supported')
  @httprettified
  @scenario(create_socket)
  def test_httpretty_debugs_socket_sendto(context):
E       fixture 'context' not found
>       available fixtures: anyio_backend, anyio_backend_name, anyio_backend_options, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, cov, doctest_namespace, monkeypatch, no_cover, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/tests/functional/test_debug.py:50
_________________________________________________________ ERROR at setup of test_httpretty_debugs_socket_recvfrom __________________________________________________________
file /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/tests/functional/test_debug.py, line 61
  @skip('not currently supported')
  @httprettified
  @scenario(create_socket)
  def test_httpretty_debugs_socket_recvfrom(context):
E       fixture 'context' not found
>       available fixtures: anyio_backend, anyio_backend_name, anyio_backend_options, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, cov, doctest_namespace, monkeypatch, no_cover, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/tests/functional/test_debug.py:61
_________________________________________________________ ERROR at setup of test_httpretty_debugs_socket_recv_into _________________________________________________________
file /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/tests/functional/test_debug.py, line 72
  @skip('not currently supported')
  @httprettified
  @scenario(create_socket)
  def test_httpretty_debugs_socket_recv_into(context):
E       fixture 'context' not found
>       available fixtures: anyio_backend, anyio_backend_name, anyio_backend_options, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, cov, doctest_namespace, monkeypatch, no_cover, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/tests/functional/test_debug.py:72
_______________________________________________________ ERROR at setup of test_httpretty_debugs_socket_recvfrom_into _______________________________________________________
file /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/tests/functional/test_debug.py, line 83
  @skip('not currently supported')
  @httprettified
  @scenario(create_socket)
  def test_httpretty_debugs_socket_recvfrom_into(context):
E       fixture 'context' not found
>       available fixtures: anyio_backend, anyio_backend_name, anyio_backend_options, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, cov, doctest_namespace, monkeypatch, no_cover, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/tests/functional/test_debug.py:83
__________________________________________________________________ ERROR at setup of test_recording_calls __________________________________________________________________
file /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/tests/functional/test_requests.py, line 770
  @use_tornado_server
  def test_recording_calls(port):
E       fixture 'port' not found
>       available fixtures: anyio_backend, anyio_backend_name, anyio_backend_options, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, cov, doctest_namespace, monkeypatch, no_cover, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/tests/functional/test_requests.py:770
================================================================================= FAILURES =================================================================================
__________________________________________________________________ test_rotating_responses_with_httplib2 ___________________________________________________________________

args = (), kw = {}, start = datetime.datetime(2022, 1, 4, 7, 41, 46, 532196), end = datetime.datetime(2022, 1, 4, 7, 41, 46, 779465)
delta = datetime.timedelta(microseconds=247269), took = 2472.69

    def wrap(*args, **kw):
        start = datetime.utcnow()

        try:
            func(start, *args, **kw)
        except TypeError as e:
            if PY2:
                # PY2 has different error message
                fmt = "{0}() takes no arguments"
            else:
                fmt = "{0}() takes 0 positional arguments but 1 was given"
            err = text_type(e)
            if fmt.format(func.__name__) in err:
                func(*args, **kw)
            else:
                exc.append(traceback.format_exc())

        except Exception as e:
            exc.append(traceback.format_exc())

        end = datetime.utcnow()
        delta = end - start
        took = convert_to(delta.microseconds)
        print(took, timeout)
>       assert took < timeout, "%s did not run within %s %s" % (
            func.__name__,
            word,
            unit,
        )
E       AssertionError: test_rotating_responses_with_httplib2 did not run within two miliseconds

/usr/lib/python3.8/site-packages/sure/__init__.py:217: AssertionError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
2472.69 2000
___________________________________________________ test_httpretty_should_support_a_list_of_successive_responses_urllib2 ___________________________________________________

args = (), kw = {}, start = datetime.datetime(2022, 1, 4, 7, 41, 49, 387239), end = datetime.datetime(2022, 1, 4, 7, 41, 49, 642311)
delta = datetime.timedelta(microseconds=255072), took = 2550.72

    def wrap(*args, **kw):
        start = datetime.utcnow()

        try:
            func(start, *args, **kw)
        except TypeError as e:
            if PY2:
                # PY2 has different error message
                fmt = "{0}() takes no arguments"
            else:
                fmt = "{0}() takes 0 positional arguments but 1 was given"
            err = text_type(e)
            if fmt.format(func.__name__) in err:
                func(*args, **kw)
            else:
                exc.append(traceback.format_exc())

        except Exception as e:
            exc.append(traceback.format_exc())

        end = datetime.utcnow()
        delta = end - start
        took = convert_to(delta.microseconds)
        print(took, timeout)
>       assert took < timeout, "%s did not run within %s %s" % (
            func.__name__,
            word,
            unit,
        )
E       AssertionError: test_httpretty_should_support_a_list_of_successive_responses_urllib2 did not run within two miliseconds

/usr/lib/python3.8/site-packages/sure/__init__.py:217: AssertionError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
2550.72 2000
============================================================================= warnings summary =============================================================================
../../../../../usr/lib/python3.8/site-packages/eventlet/support/greenlets.py:6
  /usr/lib/python3.8/site-packages/eventlet/support/greenlets.py:6: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    preserves_excinfo = (distutils.version.LooseVersion(greenlet.__version__)

../../../../../usr/lib/python3.8/site-packages/eventlet/support/greenlets.py:7
  /usr/lib/python3.8/site-packages/eventlet/support/greenlets.py:7: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    >= distutils.version.LooseVersion('0.3.2'))

tests/bugfixes/nosetests/test_430_respect_timeout.py::test_read_timeout
  /usr/lib/python3.8/site-packages/_pytest/threadexception.py:75: PytestUnhandledThreadExceptionWarning: Exception in thread Thread-18

  Traceback (most recent call last):
    File "/usr/lib64/python3.8/threading.py", line 932, in _bootstrap_inner
      self.run()
    File "/usr/lib64/python3.8/threading.py", line 870, in run
      self._target(*self._args, **self._kwargs)
    File "/home/tkloczko/rpmbuild/BUILDROOT/python-httpretty-1.1.4-3.fc35.x86_64/usr/lib/python3.8/site-packages/httpretty/core.py", line 1133, in fill_filekind
      fk.write(utf8(item) + b'\n')
  ValueError: write to closed file

    warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))

tests/functional/test_urllib2.py::test_httpretty_should_allow_forcing_headers_urllib2
  /home/tkloczko/rpmbuild/BUILDROOT/python-httpretty-1.1.4-3.fc35.x86_64/usr/lib/python3.8/site-packages/httpretty/core.py:1034: UserWarning: HTTPretty got to register the Content-Length header with "'35a'" which is not a number
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================================================================= short test summary info ==========================================================================
SKIPPED [1] ../../../../../usr/lib/python3.8/site-packages/_pytest/unittest.py:355: no redis server available for test
SKIPPED [1] ../../../../../usr/lib/python3.8/site-packages/_pytest/unittest.py:355: Skipped
ERROR tests/functional/test_bypass.py::test_httpretty_bypasses_when_disabled
ERROR tests/functional/test_bypass.py::test_httpretty_bypasses_a_unregistered_request
ERROR tests/functional/test_bypass.py::test_using_httpretty_with_other_tcp_protocols
ERROR tests/functional/test_bypass.py::test_disallow_net_connect_1
ERROR tests/functional/test_debug.py::test_httpretty_debugs_socket_send
ERROR tests/functional/test_debug.py::test_httpretty_debugs_socket_sendto
ERROR tests/functional/test_debug.py::test_httpretty_debugs_socket_recvfrom
ERROR tests/functional/test_debug.py::test_httpretty_debugs_socket_recv_into
ERROR tests/functional/test_debug.py::test_httpretty_debugs_socket_recvfrom_into
ERROR tests/functional/test_requests.py::test_recording_calls
FAILED tests/functional/test_httplib2.py::test_rotating_responses_with_httplib2 - AssertionError: test_rotating_responses_with_httplib2 did not run within two miliseconds
FAILED tests/functional/test_urllib2.py::test_httpretty_should_support_a_list_of_successive_responses_urllib2 - AssertionError: test_httpretty_should_support_a_list_of_s...
==================================================== 2 failed, 11140 passed, 2 skipped, 4 warnings, 10 errors in 38.70s ====================================================

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