I'm using Pyramid and SQLAlchemy and I have a bunch of tests. From time to time, I notice SAWarnings being issued while tests run. I hunt them down and make them go away.

The most common SAWarning I see is:

......eggs/SQLAlchemy-0.9.3-py2.7.egg/sqlalchemy/engine/default.py:562: SAWarning: Unicode type received non-unicode bind param value.

Now, I'd like my test suite to fail immediately after a SAWarning is found. How do I do this?

有帮助吗?

解决方案

use the python warnings filter:

import warnings
warnings.simplefilter("error")
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top