IMP Reference Guide
2.14.0
The Integrative Modeling Platform
|
Super class for IMP test cases. More...
Super class for IMP test cases.
This provides a number of useful IMP-specific methods on top of the standard Python unittest.TestCase
class. Test scripts should generally contain a subclass of this class, conventionally called Tests
(this makes it easier to run an individual test from the command line) and use IMP::test::main() as their main function.
Definition at line 150 of file test/__init__.py.
Public Member Functions | |
def | assertClassNames |
Check that all the classes in the module follow the IMP naming conventions. More... | |
def | assertFunctionNames |
Check that all the functions in the module follow the IMP naming conventions. More... | |
def | assertNotImplemented |
Assert that the given callable object is not implemented. More... | |
def | assertRaisesInternalException |
Assert that the given callable object raises InternalException. More... | |
def | assertRaisesUsageException |
Assert that the given callable object raises UsageException. More... | |
def | assertSequenceAlmostEqual |
Fail if the difference between any two items in the two sequences are exceed the specified number of places or delta. More... | |
def | assertShow |
Check that all the classes in modulename have a show method. More... | |
def | assertValueObjects |
Check that all the C++ classes in the module are values or objects. More... | |
def | assertXYZDerivativesInTolerance |
Assert that x,y,z analytical derivatives match numerical within a tolerance, or a percentage (of the analytical value), whichever is larger. More... | |
def | check_runnable_python_module |
Check a Python module designed to be runnable with 'python -m' to make sure it supports standard command line options. More... | |
def | check_standard_object_methods |
Check methods that every IMP::Object class should have. More... | |
def | check_unary_function_deriv |
Check the unary function func's derivatives against numerical approximations between lb and ub. More... | |
def | check_unary_function_min |
Make sure that the minimum of the unary function func over the range between lb and ub is at expected_fmin. More... | |
def | create_particles_in_box |
Create a bunch of particles in a box. More... | |
def | create_point_particle |
Make a particle with optimizable x, y and z attributes, and add it to the model. More... | |
def | failure_probability |
Estimate how likely a given block of code is to raise an AssertionError. More... | |
def | get_input_file_name |
Get the full name of an input file in the top-level test directory. More... | |
def | get_magnitude |
Get the magnitude of a list of floats. More... | |
def | get_tmp_file_name |
Get the full name of an output file in the tmp directory. More... | |
def | open_input_file |
Open and return an input file in the top-level test directory. More... | |
def | particle_distance |
Return distance between two given particles. More... | |
def | probabilistic_check |
Help handle a test which is expected to fail some fraction of the time. More... | |
def | randomize_particles |
Randomize the xyz coordinates of a list of particles. More... | |
def | run_example |
Run the named example script. More... | |
def | run_python_module |
Run a Python module as if with "python -m <modname>", with the given list of arguments as sys.argv. More... | |
def IMP.test.TestCase.assertClassNames | ( | self, | |
module, | |||
exceptions, | |||
words | |||
) |
Check that all the classes in the module follow the IMP naming conventions.
Definition at line 497 of file test/__init__.py.
def IMP.test.TestCase.assertFunctionNames | ( | self, | |
module, | |||
exceptions, | |||
words | |||
) |
Check that all the functions in the module follow the IMP naming conventions.
Definition at line 599 of file test/__init__.py.
def IMP.test.TestCase.assertNotImplemented | ( | self, | |
c, | |||
args, | |||
keys | |||
) |
Assert that the given callable object is not implemented.
Definition at line 231 of file test/__init__.py.
def IMP.test.TestCase.assertRaisesInternalException | ( | self, | |
c, | |||
args, | |||
keys | |||
) |
Assert that the given callable object raises InternalException.
This differs from unittest's assertRaises in that the test is skipped in fast mode (where internal checks are turned off).
Definition at line 224 of file test/__init__.py.
def IMP.test.TestCase.assertRaisesUsageException | ( | self, | |
c, | |||
args, | |||
keys | |||
) |
Assert that the given callable object raises UsageException.
This differs from unittest's assertRaises in that the test is skipped in fast mode (where usage checks are turned off).
Definition at line 218 of file test/__init__.py.
def IMP.test.TestCase.assertSequenceAlmostEqual | ( | self, | |
first, | |||
second, | |||
places = None , |
|||
msg = None , |
|||
delta = None |
|||
) |
Fail if the difference between any two items in the two sequences are exceed the specified number of places or delta.
See assertAlmostEqual
.
Definition at line 255 of file test/__init__.py.
def IMP.test.TestCase.assertShow | ( | self, | |
modulename, | |||
exceptions | |||
) |
Check that all the classes in modulename have a show method.
Definition at line 620 of file test/__init__.py.
def IMP.test.TestCase.assertValueObjects | ( | self, | |
module, | |||
exceptions_list | |||
) |
Check that all the C++ classes in the module are values or objects.
Definition at line 445 of file test/__init__.py.
def IMP.test.TestCase.assertXYZDerivativesInTolerance | ( | self, | |
sf, | |||
xyz, | |||
tolerance = 0 , |
|||
percentage = 0 |
|||
) |
Assert that x,y,z analytical derivatives match numerical within a tolerance, or a percentage (of the analytical value), whichever is larger.
sf
should be a ScoringFunction or Restraint, although for backwards compatibility a Model is also accepted.
Definition at line 237 of file test/__init__.py.
def IMP.test.TestCase.check_runnable_python_module | ( | self, | |
module | |||
) |
Check a Python module designed to be runnable with 'python -m' to make sure it supports standard command line options.
Definition at line 716 of file test/__init__.py.
def IMP.test.TestCase.check_standard_object_methods | ( | self, | |
obj | |||
) |
Check methods that every IMP::Object class should have.
Definition at line 413 of file test/__init__.py.
def IMP.test.TestCase.check_unary_function_deriv | ( | self, | |
func, | |||
lb, | |||
ub, | |||
step | |||
) |
Check the unary function func's derivatives against numerical approximations between lb and ub.
Definition at line 395 of file test/__init__.py.
def IMP.test.TestCase.check_unary_function_min | ( | self, | |
func, | |||
lb, | |||
ub, | |||
step, | |||
expected_fmin | |||
) |
Make sure that the minimum of the unary function func over the range between lb and ub is at expected_fmin.
Definition at line 403 of file test/__init__.py.
def IMP.test.TestCase.create_particles_in_box | ( | self, | |
model, | |||
num = 10 , |
|||
lb = [0 , |
|||
ub = [10 |
|||
) |
Create a bunch of particles in a box.
Definition at line 430 of file test/__init__.py.
def IMP.test.TestCase.create_point_particle | ( | self, | |
model, | |||
x, | |||
y, | |||
z | |||
) |
Make a particle with optimizable x, y and z attributes, and add it to the model.
Definition at line 327 of file test/__init__.py.
def IMP.test.TestCase.failure_probability | ( | self, | |
testcall | |||
) |
Estimate how likely a given block of code is to raise an AssertionError.
Definition at line 361 of file test/__init__.py.
def IMP.test.TestCase.get_input_file_name | ( | self, | |
filename | |||
) |
Get the full name of an input file in the top-level test directory.
Definition at line 184 of file test/__init__.py.
def IMP.test.TestCase.get_magnitude | ( | self, | |
vector | |||
) |
Get the magnitude of a list of floats.
Definition at line 213 of file test/__init__.py.
def IMP.test.TestCase.get_tmp_file_name | ( | self, | |
filename | |||
) |
Get the full name of an output file in the tmp directory.
The directory containing this file will be automatically cleaned up when the test completes.
Definition at line 205 of file test/__init__.py.
def IMP.test.TestCase.open_input_file | ( | self, | |
filename, | |||
mode = 'rb' |
|||
) |
Open and return an input file in the top-level test directory.
Definition at line 200 of file test/__init__.py.
def IMP.test.TestCase.particle_distance | ( | self, | |
p1, | |||
p2 | |||
) |
Return distance between two given particles.
Definition at line 385 of file test/__init__.py.
def IMP.test.TestCase.probabilistic_check | ( | self, | |
testcall, | |||
chance_of_failure | |||
) |
Help handle a test which is expected to fail some fraction of the time.
The test is run multiple times and an exception is thrown only if it fails too many times.
Definition at line 337 of file test/__init__.py.
def IMP.test.TestCase.randomize_particles | ( | self, | |
particles, | |||
deviation | |||
) |
Randomize the xyz coordinates of a list of particles.
Definition at line 374 of file test/__init__.py.
def IMP.test.TestCase.run_example | ( | self, | |
filename | |||
) |
Run the named example script.
Definition at line 650 of file test/__init__.py.
def IMP.test.TestCase.run_python_module | ( | self, | |
module, | |||
args | |||
) |
Run a Python module as if with "python -m <modname>", with the given list of arguments as sys.argv.
If module is an already-imported Python module, run its 'main' function and return the result.
If module is a string, run the module in a subprocess and return a subprocess.Popen-like object containing the child stdin, stdout and stderr.
Definition at line 681 of file test/__init__.py.