minrk / wurlitzer

Capture C-level stdout/stderr in Python
MIT License
194 stars 24 forks source link

Python 3.10 test regression #53

Closed mgorny closed 3 years ago

mgorny commented 3 years ago

Bug description

The test suite is failing with Python 3.10.0rc1 in the 3.0.1 release (3.0.0 passed fine).

Expected behaviour

Passing tests ;-).

Actual behaviour

========================================================= test session starts =========================================================
platform linux -- Python 3.10.0rc1, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 -- /usr/bin/python3.10
cachedir: .pytest_cache
metadata: {'Python': '3.10.0rc1', 'Platform': 'Linux-5.13.12-gentoo-dist-x86_64-AMD_Ryzen_5_3600_6-Core_Processor-with-glibc2.33', 'Packages': {'pytest': '6.2.4', 'py': '1.10.0', 'pluggy': '0.13.1'}, 'Plugins': {'case': '1.5.3', 'mock': '3.6.1', 'expect': '1.1.0', 'forked': '1.3.0', 'asyncio': '0.15.1', 'freezegun': '0.4.2', 'timeout': '1.4.2', 'datadir': '1.3.1', 'metadata': '1.8.0', 'snapshottest': '0.5.1', 'subtests': '0.5.0', 'localserver': '0.5.0', 'betamax': '0.8.1', 'pyfakefs': '4.5.0', 'httpbin': '1.0.0', 'django': '4.4.0', 'shutil': '1.7.0', 'virtualenv': '1.7.0', 'xdist': '2.3.0', 'cov': '2.12.1', 'rerunfailures': '10.1', 'flaky': '3.7.0', 'services': '2.2.1', 'requests-mock': '1.9.3', 'lazy-fixture': '0.6.3', 'xprocess': '0.18.1', 'aiohttp': '0.3.0', 'regressions': '2.2.0', 'typeguard': '2.12.1', 'xdoctest': '0.15.6', 'anyio': '3.2.1', 'toolbox': '0.4', 'pkgcore': '0.12.4', 'describe': '2.0.0', 'httpx': '0.13.0', 'hypothesis': '6.15.0', 'Faker': '8.12.1'}, 'JAVA_HOME': '/etc/java-config-2/current-system-vm'}
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/tmp/portage/dev-python/wurlitzer-3.0.1/work/wurlitzer-3.0.1/.hypothesis/examples')
rootdir: /tmp/portage/dev-python/wurlitzer-3.0.1/work/wurlitzer-3.0.1
plugins: case-1.5.3, mock-3.6.1, expect-1.1.0, forked-1.3.0, asyncio-0.15.1, freezegun-0.4.2, timeout-1.4.2, datadir-1.3.1, metadata-1.8.0, snapshottest-0.5.1, subtests-0.5.0, localserver-0.5.0, betamax-0.8.1, pyfakefs-4.5.0, httpbin-1.0.0, django-4.4.0, shutil-1.7.0, virtualenv-1.7.0, xdist-2.3.0, cov-2.12.1, rerunfailures-10.1, flaky-3.7.0, services-2.2.1, requests-mock-1.9.3, lazy-fixture-0.6.3, xprocess-0.18.1, aiohttp-0.3.0, regressions-2.2.0, typeguard-2.12.1, xdoctest-0.15.6, anyio-3.2.1, toolbox-0.4, pkgcore-0.12.4, describe-2.0.0, httpx-0.13.0, hypothesis-6.15.0, Faker-8.12.1
collecting ... collected 12 items

test.py::test_pipes PASSED                                                                                                      [  8%]
test.py::test_pipe_bytes PASSED                                                                                                 [ 16%]
test.py::test_forward PASSED                                                                                                    [ 25%]
test.py::test_pipes_stderr PASSED                                                                                               [ 33%]
test.py::test_flush PASSED                                                                                                      [ 41%]
test.py::test_sys_pipes PASSED                                                                                                  [ 50%]
test.py::test_redirect_everything PASSED                                                                                        [ 58%]
test.py::test_fd_leak PASSED                                                                                                    [ 66%]
test.py::test_buffer_full PASSED                                                                                                [ 75%]
test.py::test_buffer_full_default PASSED                                                                                        [ 83%]
test.py::test_pipe_max_size PASSED                                                                                              [ 91%]
test.py::test_bufsize FAILED                                                                                                    [100%]

============================================================== FAILURES ===============================================================
____________________________________________________________ test_bufsize _____________________________________________________________

    @pytest.mark.skipif(
        wurlitzer._get_max_pipe_size() is None, reason="requires _get_max_pipe_size"
    )
    def test_bufsize():
        default_bufsize = wurlitzer._get_max_pipe_size()
        with wurlitzer.pipes() as (stdout, stderr):
>           assert fcntl(sys.__stdout__, wurlitzer.F_GETPIPE_SZ) == default_bufsize
E           AttributeError: module 'wurlitzer' has no attribute 'F_GETPIPE_SZ'

default_bufsize = 1048576
stderr     = <_io.StringIO object at 0x7fd0e08fb2e0>
stdout     = <_io.StringIO object at 0x7fd0e08fb250>

test.py:173: AttributeError
======================================================= short test summary info =======================================================
FAILED test.py::test_bufsize - AttributeError: module 'wurlitzer' has no attribute 'F_GETPIPE_SZ'
==================================================== 1 failed, 11 passed in 1.00s =====================================================

How to reproduce

python3.10 -m pytest test.py

Your personal set up

minrk commented 3 years ago

Thanks! Looks like 3.10 finally defines these symbols and the test only works if the missing-import path is taken. Fixed by #54