pytest-dev / pytest-flask

A set of pytest fixtures to test Flask applications

Home Page:http://pytest-flask.readthedocs.org/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

debugging live_server crash

fgregg opened this issue · comments

Hi there!

Thanks for the great library.

I have a test like this

@pytest.mark.usefixtures('live_server')
def test_cookie_getting(setup):
    sesh = requests.Session()

    username = 'foo'
    password = 'bar'

    response = sesh.post(
        url_for('security.login', _external=True),
        data={'email': username, 'password': password, 'next': None},
    )

    ...

When the requests makes the post, it kills the server. The test ends up exiting with a Connection aborted exception.

I'm not sure why the server is halting. Do you have suggestions for getting messages or tracebacks from live_server?

Possible clue. Sometimes I get this traceback in the pytest output:

----------------------------- Captured stderr call -----------------------------
objc[28861]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called.
objc[28861]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.

Hey @fgregg, thanks for letting us know about the issue. I have created a minimal example with the provided test, but I'm afraid I wasn't able to reproduce the crash.

Test run output:

platform darwin -- Python 3.7.8, pytest-6.1.1, py-1.9.0, pluggy-0.13.1
plugins: flask-1.0.0
collected 1 item

tests/test_live_server.py . [100%]

===========================1 passed in 5.17s================================

Could you please provide more details about your environment? our perhaps (even better) a minimal, reproducible example?

Closing for now, feel free to reopen to provide the necessary information.