Last active
August 29, 2015 14:12
-
-
Save jobovy/05b711288da43ae7e29d to your computer and use it in GitHub Desktop.
Show python3 warnings for specific module when running a test suite with nose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run this as | |
# python -3 MODULE TESTFILE NOSETESTS_OPTIONS | |
# where: | |
# MODULE: module that you want to check for python3 compatibility | |
# TESTFILE: file with tests | |
# NOSETESTS OPTIONS: other options that you would give to nosetests (e.g., -v, -x, --nocapture) | |
import sys | |
import warnings | |
import nose | |
if __name__ == '__main__': | |
module= sys.argv[1] | |
testfile= sys.argv[2] | |
warnings.filterwarnings('ignore','',DeprecationWarning,'^((?!%s).)*$' % module) | |
# Following line turns the warnings into errors | |
warnings.filterwarnings('error','',DeprecationWarning,module) | |
argv= ['blahblah',testfile] #nose.main ignores argv[0] | |
argv.extend(sys.argv[3:]) | |
nose.main(argv=argv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment