New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recent logging change breaks under tests #922
Comments
Hello @asherf, thank you for the report. We will likely need to revert that change. So far, I have been unable to reproduce: $ python
Python 3.9.11 (main, Sep 22 2022, 13:08:52)
[Clang 14.0.0 (clang-1400.0.29.102)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import stripe
>>> stripe.version.VERSION
'5.1.0'
>>>
$ cat test_blah.py
import stripe
def test_stripe_api():
stripe.api_key = "sk_test_xyz"
stripe.api_base = "http://localhost:12111" # points to a locally running stripe-mock
stripe.Customer.search(query='metadata["toolchain_id"]:"george" AND metadata["toolchain_env"]:"jerry"')
$ python -m pytest test_blah.py
========================================= test session starts ==========================================
platform darwin -- Python 3.9.11, pytest-7.2.1, pluggy-1.0.0
rootdir: /Users/richardm/testbed/python
collected 1 item
test_blah.py . [100%]
========================================== 1 passed in 0.08s =========================================== Would love to figure out how this is happening in your scenario but not this one. |
hmm... maybe it has something to do with how our logging is configured under tests (we have a bunch of setup code that uses conftest). |
Ah, I triggered it with
I will spend some time investigating, and I will push either a fix or a revert shortly. |
import stripe
import logging
def test_stripe_api():
logging.config.dictConfig(
{
"loggers": {
"": {"handlers": ["console"], "level": "INFO"},
},
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"default": {
"format": "[%(asctime)s %(levelname)s %(process)d %(pathname)s:%(lineno)s] %(message)s",
"datefmt": "%Y-%m-%d %H:%M:%S",
}
},
"handlers": {
"console": {
"class": "logging.StreamHandler",
"level": "DEBUG",
"formatter": "default",
}
},
}
)
stripe.api_key = "no-soup-for-you"
stripe.api_base = "https://jerry.not-stripe.fake"
stripe.Customer.search(query='metadata["toolchain_id"]:"george" AND metadata["toolchain_env"]:"jerry"') This will also trigger it. |
awesome. thanks! |
I can reproduce without pytest too :/
|
I've released 5.1.1 with the revert, and also yanked 5.1.0 from PyPi |
thanks for the fast turnaround on this! |
Describe the bug
We see this exception when using version 5.1.0 of the stripe sdk,
I suspect this change: #913 caused the issue.
as you can see this happens when running under test so possibly something is broken in the interaction between stripe's logging wrappers and pytest caplog mechanism used to capture logs.
To Reproduce
this test will repo the exception when running under pytest.
note that this test will fail because the network call is not mocked in this snippet, but w/ 5.1.0 it will fail before trying to make the network call.
Expected behavior
not to break/fail.
Code snippets
No response
OS
all platforms (linux/mac)
Language version
Python 3.9.12
Library version
5.1.0
API version
2022-11-15
Additional context
No response
The text was updated successfully, but these errors were encountered: