Kim*_*cks 1 python django pytest
https://docs.pytest.org/en/6.2.x/warnings.html#deprecationwarning-and-pendingdeprecationwarning教我在 pytest.ini 中使用它
filterwarnings = ignore:.*U.*mode is deprecated:DeprecationWarning
但我仍然收到这样的警告:
../usr/local/lib/python3.8/dist-packages/django/apps/registry.py:91
/usr/local/lib/python3.8/dist-packages/django/apps/registry.py:91: RemovedInDjango41Warning: 'pattern_library' defines default_app_config = 'pattern_library.apps.PatternLibraryAppConfig'. Django now detects this configuration automatically. You can remove default_app_config.
app_config = AppConfig.create(entry)
Run Code Online (Sandbox Code Playgroud)
我也想抑制这一点,因为这也是我无法控制的第三方库,尽管我已经提交了 PR 来更新它。
我应该在 pytest.ini 中添加什么?
您可以在给定警告类别的完整导入路径上注册过滤器;这是django.utils.deprecation.RemovedInDjango41Warning:
filterwarnings =
ignore:.*U.*mode is deprecated:DeprecationWarning
ignore:.*Django now detects this configuration.*:django.utils.deprecation.RemovedInDjango41Warning
Run Code Online (Sandbox Code Playgroud)
根据您的 Django 版本,RemovedInDjango41Warning是DeprecationWarning(Django 4.0,仍在开发中)或PendingDeprecationWarning(Django 3.2)的子类,并且警告过滤器也与子类匹配,因此:
ignore:.*Django now detects this configuration.*:PendingDeprecationWarning
ignore:.*Django now detects this configuration.*:DeprecationWarning
Run Code Online (Sandbox Code Playgroud)
对于 Django 3.2 和 4.0 也适用。
| 归档时间: |
|
| 查看次数: |
1447 次 |
| 最近记录: |