Test-driven development

Test-driven development

TDD is one of the most important milestones in the history of software development. TDD primarily focused on automated unit testing, its goal is to maximize automated test code. If the code is changed, we can still run the test and catch possible problems. In other words, the test is still valid for the function modules already exist.

Predicate function

Comparing two floating point numbers Size:

assert_almost_equal if the degree of approximation of the two numbers does not reach the specified accuracy, throwing an exception

assert_approx_equal if the degree of approximation of the two numbers do not reach the specified valid number, throwing an exception

If the degree of approximation assert_array_almost_equal two arrays of elements does not reach the specified accuracy, throwing an exception

assert_array_equal if the two are not the same array object, throwing an exception

assert_array_less two arrays have the same shape, and the first array element is strictly less than the second element of the array, or to throw an exception

assert_equal If two objects are not the same, throwing an exception

assert_raises if called with the fill parameter is not specified exception is thrown, the test does not pass

assert_warns if not thrown specified warning, do not pass the test

two identical string variables asserted assert_string_equal

If the degree of approximation assert_allclose two objects exceeds the specified tolerance limits, will throw an exception

# Assert_allclose degree of approximation if two objects exceeds the specified tolerance limits, it is thrown 
from numpy.testing Import assert_allclose 
assert_allclose (np.sum (Q_I), . 1, ERR_MSG = " {} " .format (np.sum (q_i)))

 

Guess you like

Origin www.cnblogs.com/TimVerion/p/11344362.html