1

What's Happening

I'm writing acceptance tests with selenium-python and pytest on python 2.7. Whenever a test fails the CLI output is flooded with debug output under ---captured log call--- for every failed test.

Example

remote_connection.py       480 DEBUG    POST http://127.0.0.1:52030/session/3561e266d0                                                                                              c9dd090e0a4d68923e9c1f/element {"using": "id", "sessionId": "3561e266d0c9dd090e0a4d689                                                                                              23e9c1f", "value": "valueFx"}
remote_connection.py       567 DEBUG    Finished Request {u'status': 0, u'sessionId':                                                                                               u'3561e266d0c9dd090e0a4d68923e9c1f', u'value': {u'ELEMENT': u'0.40203467536832127-1'}}
remote_connection.py       480 DEBUG    POST http://127.0.0.1:52030/session/3561e266d0                                                                                              c9dd090e0a4d68923e9c1f/element/0.40203467536832127-1/click {"sessionId": "3561e266d0c9                                                                                              dd090e0a4d68923e9c1f", "id": "0.40203467536832127-1"}
remote_connection.py       567 DEBUG    Finished Request {u'status': 0, u'sessionId':                                                                                               u'3561e266d0c9dd090e0a4d68923e9c1f', u'value': None}
remote_connection.py       480 DEBUG    POST http://127.0.0.1:52030/session/3561e266d0                                                                                              c9dd090e0a4d68923e9c1f/element {"using": "id", "sessionId": "3561e266d0c9dd090e0a4d689                                                                                              23e9c1f", "value": "leftValue"}
remote_connection.py       567 DEBUG    Finished Request {u'status': 0, u'sessionId':                                                                                               u'3561e266d0c9dd090e0a4d68923e9c1f', u'value': {u'ELEMENT': u'0.40203467536832127-28'}                                                                                              }
remote_connection.py       480 DEBUG    POST http://127.0.0.1:52030/session/3561e266d0                                                                                              c9dd090e0a4d68923e9c1f/element {"using": "id", "sessionId": "3561e266d0c9dd090e0a4d689                                                                                              23e9c1f", "value": "rightValue"}
remote_connection.py       567 DEBUG    Finished Request {u'status': 0, u'sessionId':                                                                                               u'3561e266d0c9dd090e0a4d68923e9c1f', u'value': {u'ELEMENT': u'0.40203467536832127-29'}                                                                                              }
remote_connection.py       480 DEBUG    POST http://127.0.0.1:52030/session/3561e266d0                                                                                              c9dd090e0a4d68923e9c1f/element {"using": "id", "sessionId": "3561e266d0c9dd090e0a4d689                                                                                              23e9c1f", "value": "leftFXMove"}
remote_connection.py       567 DEBUG    Finished Request {u'status': 0, u'sessionId':                                                                                               u'3561e266d0c9dd090e0a4d68923e9c1f', u'value': {u'ELEMENT': u'0.40203467536832127-30'}                                                                                              }
remote_connection.py       480 DEBUG    POST http://127.0.0.1:52030/session/3561e266d0                                                                                              c9dd090e0a4d68923e9c1f/element {"using": "id", "sessionId": "3561e266d0c9dd090e0a4d689                                                                                              23e9c1f", "value": "RightFXMove"}
remote_connection.py       567 DEBUG    Finished Request {u'status': 0, u'sessionId':                                                                                               u'3561e266d0c9dd090e0a4d68923e9c1f', u'value': {u'ELEMENT': u'0.40203467536832127-31'}                                                                                              }
remote_connection.py       480 DEBUG    GET http://127.0.0.1:52030/session/3561e266d0c                                                                                              9dd090e0a4d68923e9c1f/element/0.40203467536832127-28/text {"sessionId": "3561e266d0c9d                                                                                              d090e0a4d68923e9c1f", "id": "0.40203467536832127-28"}
remote_connection.py       567 DEBUG    Finished Request {u'status': 0, u'sessionId':                                                                                               u'3561e266d0c9dd090e0a4d68923e9c1f', u'value': u''}
remote_connection.py       480 DEBUG    POST http://127.0.0.1:52030/session/3561e266d0                                                                                              c9dd090e0a4d68923e9c1f/element {"using": "id", "sessionId": "3561e266d0c9dd090e0a4d689                                                                                              23e9c1f", "value": "leftValue"}
remote_connection.py       567 DEBUG    Finished Request {u'status': 0, u'sessionId':                                                                                               u'3561e266d0c9dd090e0a4d68923e9c1f', u'value': {u'ELEMENT': u'0.40203467536832127-28'}                                                                                              }
remote_connection.py       480 DEBUG    GET http://127.0.0.1:52030/session/3561e266d0c                                                                                              9dd090e0a4d68923e9c1f/element/0.40203467536832127-28/text {"sessionId": "3561e266d0c9d                                                                                              d090e0a4d68923e9c1f", "id": "0.40203467536832127-28"}
remote_connection.py       567 DEBUG    Finished Request {u'status': 0, u'sessionId':                                                                                               u'3561e266d0c9dd090e0a4d68923e9c1f', u'value': u''}
remote_connection.py       480 DEBUG    POST http://127.0.0.1:52030/session/3561e266d0                                                                                              c9dd090e0a4d68923e9c1f/element {"using": "id", "sessionId": "3561e266d0c9dd090e0a4d689                                                                                              23e9c1f", "value": "leftValue"}
remote_connection.py       567 DEBUG    Finished Request {u'status': 0, u'sessionId':                                                                                               u'3561e266d0c9dd090e0a4d68923e9c1f', u'value': {u'ELEMENT': u'0.40203467536832127-28'}                                                                                              }
remote_connection.py       480 DEBUG    GET http://127.0.0.1:52030/session/3561e266d0c                                                                                              9dd090e0a4d68923e9c1f/element/0.40203467536832127-28/text {"sessionId": "3561e266d0c9d                                                                                              d090e0a4d68923e9c1f", "id": "0.40203467536832127-28"}
remote_connection.py       567 DEBUG    Finished Request {u'status': 0, u'sessionId':                                                                                               u'3561e266d0c9dd090e0a4d68923e9c1f', u'value': u''}
remote_connection.py       480 DEBUG    POST http://127.0.0.1:52030/session/3561e266d0                                                                                              c9dd090e0a4d68923e9c1f/element {"using": "id", "sessionId": "3561e266d0c9dd090e0a4d689                                                                                              23e9c1f", "value": "leftValue"}
remote_connection.py       567 DEBUG    Finished Request {u'status': 0, u'sessionId':                                                                                               u'3561e266d0c9dd090e0a4d68923e9c1f', u'value': {u'ELEMENT': u'0.40203467536832127-28'}                                                                                              }
remote_connection.py       480 DEBUG    GET http://127.0.0.1:52030/session/3561e266d0c                                                                                              9dd090e0a4d68923e9c1f/element/0.40203467536832127-28/text {"sessionId": "3561e266d0c9d                                                                                              d090e0a4d68923e9c1f", "id": "0.40203467536832127-28"}
remote_connection.py       567 DEBUG    Finished Request {u'status': 0, u'sessionId':                                                                                               u'3561e266d0c9dd090e0a4d68923e9c1f', u'value': u''}
remote_connection.py       480 DEBUG    POST http://127.0.0.1:52030/session/3561e266d0                                                                                              c9dd090e0a4d68923e9c1f/element {"using": "id", "sessionId": "3561e266d0c9dd090e0a4d689                                                                                              23e9c1f", "value": "leftValue"}
remote_connection.py       567 DEBUG    Finished Request {u'status': 0, u'sessionId':                                                                                               u'3561e266d0c9dd090e0a4d68923e9c1f', u'value': {u'ELEMENT': u'0.40203467536832127-28'}                                                                                              }
remote_connection.py       480 DEBUG    GET http://127.0.0.1:52030/session/3561e266d0c                                                                                              9dd090e0a4d68923e9c1f/element/0.40203467536832127-28/text {"sessionId": "3561e266d0c9d                                                                                              d090e0a4d68923e9c1f", "id": "0.40203467536832127-28"}
remote_connection.py       567 DEBUG    Finished Request {u'status': 0, u'sessionId':                                                                                               u'3561e266d0c9dd090e0a4d68923e9c1f', u'value': u''}
remote_connection.py       480 DEBUG    POST http://127.0.0.1:52030/session/3561e266d0                                                                                              c9dd090e0a4d68923e9c1f/element {"using": "id", "sessionId": "3561e266d0c9dd090e0a4d689                                                                                              23e9c1f", "value": "leftValue"}
remote_connection.py       567 DEBUG    Finished Request {u'status': 0, u'sessionId':                                                                                               u'3561e266d0c9dd090e0a4d68923e9c1f', u'value': {u'ELEMENT': u'0.40203467536832127-28'}                                                                                              }
remote_connection.py       480 DEBUG    GET http://127.0.0.1:52030/session/3561e266d0c                                                                                              9dd090e0a4d68923e9c1f/element/0.40203467536832127-28/text {"sessionId": "3561e266d0c9d                                                                                              d090e0a4d68923e9c1f", "id": "0.40203467536832127-28"}
remote_connection.py       567 DEBUG    Finished Request {u'status': 0, u'sessionId':                                                                                               u'3561e266d0c9dd090e0a4d68923e9c1f', u'value': u''}
remote_connection.py       480 DEBUG    POST http://127.0.0.1:52030/session/3561e266d0                                                                                              c9dd090e0a4d68923e9c1f/element {"using": "id", "sessionId": "3561e266d0c9dd090e0a4d689                                                                                              23e9c1f", "value": "leftValue"}
remote_connection.py       567 DEBUG    Finished Request {u'status': 0, u'sessionId':                                                                                               u'3561e266d0c9dd090e0a4d68923e9c1f', u'value': {u'ELEMENT': u'0.40203467536832127-28'}                                                                                              }
remote_connection.py       480 DEBUG    GET http://127.0.0.1:52030/session/3561e266d0c                                                                                              9dd090e0a4d68923e9c1f/element/0.40203467536832127-28/text {"sessionId": "3561e266d0c9d                                                                                              d090e0a4d68923e9c1f", "id": "0.40203467536832127-28"}
remote_connection.py       567 DEBUG    Finished Request {u'status': 0, u'sessionId':                                                                                               u'3561e266d0c9dd090e0a4d68923e9c1f', u'value': u'-110459.82231227'}

That's for 1 test failure! When I have N failures, this debug output is multiplied for every test. Compared to the 10-20 lines pytest outputs showing my failed test and the exception raised, this is both needlessly verbose and time-consuming to search through.

Running in quiet mode doesn't remove this output either.

pytest tests/acceptance/pricers/test_fxfwd.py -q

or running with multiple flags of -q...

How then do I remove this debug output or otherwise prevent it from being displayed for failed tests?

1 Answer 1

2

You can confirm this in your pytest.ini like this.

[pytest] 
log_print = False

You can also add log_format options to send different log levels to different files , you will at some point want to see those logs.

For the full options and more background the docs are here https://docs.pytest.org/en/latest/logging.html

If the file is not present, add pytest.ini in the root directory of your test suite.

1
  • 1
    Thanks, that did the trick! (I didn't even have a pytest config file). Commented Mar 6, 2018 at 19:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.