You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I was wondering why my code was returning True for testing when I wasn't testing it (it behave differently when testing, such as not really sending emails).
After looking, I found out that Sanic/app.py loop over the SANIC_PACKAGES list, which includes "sanic-testing", and if present, import them.
When importing Sanic testing, this package change the test_mode to True, which is not true until the Sanic Testing package has been instantiated. IMHO, it should only change the state to true when enabled, not when imported
Code snippet
app.py, line 1836
for package_name in SANIC_PACKAGES:
module_name = package_name.replace("-", "_")
try:
module = import_module(module_name)
packages.append(f"{package_name}=={module.__version__}")
except ImportError:
...
Expected behavior
Importing "sanic-testing" shouldn't change the state of Sanic (test_mode). Only when instantiating it.
Environment (please complete the following information):
OS: Fedora 32 v5.11.22-100.fc32.x86_64
Python: 3.8.10
Sanic version : 21.12.1
The text was updated successfully, but these errors were encountered:
Describe the bug
I was wondering why my code was returning True for testing when I wasn't testing it (it behave differently when testing, such as not really sending emails).
After looking, I found out that Sanic/app.py loop over the SANIC_PACKAGES list, which includes "sanic-testing", and if present, import them.
When importing Sanic testing, this package change the
test_mode
to True, which is not true until the Sanic Testing package has been instantiated. IMHO, it should only change the state totrue
when enabled, not when importedCode snippet
app.py, line 1836
Expected behavior
Importing "sanic-testing" shouldn't change the state of Sanic (test_mode). Only when instantiating it.
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: