How can I have nose re-run only tests that failed?

EDIT June 2021: Surprised this is still getting votes. If at all possible, consider using ptyest with the –last-failed option. It turns out this is trivial with nose. First run the command and include the –with-id flag. # Environment stuff deleted nosetests python/*Tests.py -v –with-id nosetests python/*Tests.py -v –failed If, say, four tests fail, running … Read more

Python unitest – Use variables defined in module and class level setup functions, in tests

For the string variable a, the only solution is global a. If you look at the Python 2 and Python 3 source code, setupModule() doesn’t appear to do anything magical, so all the usual namespace rules apply. If a were a mutable variable, like a list, you could define it at global scope and then … Read more

How to suppress verbose Tensorflow logging? [duplicate]

2.0 Update (10/8/19) Setting TF_CPP_MIN_LOG_LEVEL should still work (see below in v0.12+ update), but there is currently an issue open (see issue #31870). If setting TF_CPP_MIN_LOG_LEVEL does not work for you (again, see below), try doing the following to set the log level: import tensorflow as tf tf.get_logger().setLevel(‘INFO’) In addition, please see the documentation on … Read more

How should we test exceptions with nose?

nose provides tools for testing exceptions (like unittest does). Try this example (and read about the other tools at Nose Testing Tools from nose.tools import * l = [] d = dict() @raises(Exception) def test_Exception1(): ”’this test should pass”’ l.pop() @raises(KeyError) def test_Exception2(): ”’this test should pass”’ d[1] @raises(KeyError) def test_Exception3(): ”’this test should fail … Read more

ModuleNotFoundError: No module named ‘numpy.testing.nosetester’

This is happening due to a version incompatibility between numpy and scipy. numpy in its latest versions have deprecated numpy.testing.nosetester. Replicating the issue pip install numpy==1.18 # > 1.18 pip install scipy<=0.19.0 # <= 0.19 and from sklearn.tree import DecisionTreeClassifier as DTC Triggers the error. Fixing the error Upgrade your scipy to a higher version. … Read more

Nose unable to find tests in ubuntu

The other thing which always gets me with nose is that it won’t run tests in executable files. I’m not exactly sure why that would make a difference across Mac/Ubuntu, but it’s worth a shot. Make sure that the scripts didn’t somehow get chmod +x‘d on the Mac… And if they did, fix them with … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)