def tearDown(self): sys.argv = self.storeArgv written_test_files = [ get_relative_path("test_{:s}.pdb".format(shape)) for shape in self.geometries.keys() ] for file in written_test_files: if os.path.exists(file): os.remove(file)
def test_raises_execeptions(self): flat_reference = Molecules( get_relative_path("reference_files/test_classes/reference.pdb")) baseshape = shapes.shape() with self.assertRaises(NotImplementedError): baseshape.gen_shape(flat_reference, 0) with self.assertRaises(NotImplementedError): baseshape.dimension_requirements() with self.assertRaises(NotImplementedError): baseshape.final_dimensions()
def test_shapes(self): base_args = len(sys.argv) for shape, geometry in self.geometries.items(): sys.argv.extend([ "-s", shape, "-o", get_relative_path("test_{:s}.pdb".format(shape)), "-g" ]) sys.argv.extend(geometry) bumpy.main() success = PDBComp.compareAtomFields( get_relative_path("test_{:s}.pdb".format(shape)), get_relative_path( "reference_files/test_shapes/test_{:s}.pdb".format(shape))) if not success: os.rename("test_{:s}.pdb".format(shape), "failed_test_{:s}.pdb".format(shape)) self.assertTrue(success, "Failure in shape {:s}".format(shape)) sys.argv = sys.argv[:base_args]
def setUp(self): self.invalidArgs = emptyArgs() self.invalidArgs.s = "sphere" self.invalidArgs.f = get_relative_path( "reference_files/test_user_interface/reference.pdb") self.invalidArgs.z = "10" self.invalidArgs.o = "output.pdb" self.invalidArgs.p = None self.invalidArgs.n = None # redirect stderr for text checking self.stderr = std_checker() self.stored_stderr = sys.stderr sys.stderr = self.stderr
def setUp(self): class args: pass self.validArgs = args() self.validArgs.s = "sphere" self.validArgs.f = get_relative_path( "reference_files/test_user_interface/reference.pdb") self.validArgs.z = "10" self.validArgs.g = ["r_sphere:100"] self.validArgs.o = "argument_check_output.pdb" self.validArgs.p = None self.validArgs.n = None # redirect stderr for text checking self.stderr = std_checker() self.stored_stderr = sys.stderr sys.stderr = self.stderr
def setUp(self): self.geometries = { 'buckle': ['r_buckle:50', 'l_buckle:60'], 'capped_cylinder': ['r_cylinder:50', 'l_cylinder:60'], 'cylinder': ['r_cylinder:50', 'l_cylinder:60'], 'double_bilayer_cylinder': ['r_cylinder:50', 'l_cylinder:50', 'r_junction:40', 'l_flat:250'], 'flat_bilayer': ['x_dimension:50', 'y_dimension:40'], 'inner_quarter_torus': ['r_torus:75', 'r_tube:50'], 'outer_quarter_torus': ['r_torus:75', 'r_tube:50'], 'semicylinder_plane': ['r_cylinder:50', 'l_cylinder:30', 'r_junction:40', 'l_flat:50'], 'semisphere': ['r_sphere:50'], 'semisphere_plane': ['r_sphere:50', 'r_junction:30', 'l_flat:200'], 'sphere': ['r_sphere:50'], 'torus': ['r_torus:75', 'r_tube:50'] } self.storeArgv = sys.argv sys.argv = [ "bumpy.py", "-z", "10", "-f", get_relative_path("reference_files/input/input_asymm.gro") ]
def test_dummy_topology(self): sys.argv.extend(["-f", get_relative_path("reference_files/input/input_asymm.gro"), "-p", "topol_with_dummy.top", "--gen_dummy_particles", "--dummy_grid_thickness", "50"]) bumpy.main() self.assertTrue(FileComp.filesMatchExactly("topol_with_dummy.top", get_relative_path("reference_files/test_topology/topol_with_dummy.top")))
def test_complex_topology(self): sys.argv.extend(["-f", get_relative_path("reference_files/input/input_asymm.gro"), "-p", "topol_complex.top"]) bumpy.main() self.assertTrue(FileComp.filesMatchExactly("topol_complex.top", get_relative_path("reference_files/test_topology/topol_complex.top")))
def setUp(self): self.flat_reference = Molecules( get_relative_path("reference_files/test_classes/reference.pdb")) self.flat_reference.duplicate_laterally( 3, 3) # should be large enough for all shapes