Turn off sqlalchemy warnings in nosetests

Viewed 2165

I'm trying to suppress all sqlalchemy warnings while running my test suite with nosetests. I read Turn off a warning in sqlalchemy

.............................../Users/ca/.pythonbrew/venvs/Python-2.7.3/api/lib/python2.7/site-packages/SQLAlchemy-0.7.5-py2.7-macosx-10.7-x86_64.egg/sqlalchemy/engine/default.py:330: Warning: Field 'random_id' doesn't have a default value
cursor.execute(statement, parameters)

I included this in my package's __init__.py file:

def setup_package():
    """Setup the test during the whole session.

    Run by nosetests
    """
    # Suppress all SQLAlchemy warnings
    warnings.filterwarnings("ignore", category=sa_exc.SAWarning)

With the proper imports. I know it is run by nosetests because I tried some other stuff which raised error. The only thing is that it has no effect whatsoever. Warnings are still displayed.

Any idea?

Thanks!

1 Answers
Related