def test__get_atomsection_raises(): """Test if ValueError is raised if input list is not in the mol2 format.""" expect = ("Structural data could not be loaded. " "Is the input file/text in the mol2 format?") def run_code(): PandasMol2()._get_atomsection(["", ""]) assert_raises(ValueError, expect, run_code)
def test_split_multimol2_wrong_format(): expect = ('Wrong file format;' 'allowed file formats are .mol2 and .mol2.gz.') def run_code(): next(split_multimol2('40_mol2_files.pdb')) assert_raises(ValueError, expect, run_code)
def test_overwrite_df(): data_path = os.path.join(this_dir, 'data', '1b5e_1.mol2') pdmol = PandasMol2().read_mol2(data_path) def overwrite(): pdmol.df = pdmol.df[(pdmol.df['atom_type'] != 'H')] expect = ('Please use `PandasMol2._df = ... `' ' instead\nof `PandasMol2.df = ... `' ' if you are sure that\nyou want' ' to overwrite the `df` attribute.') assert_raises(AttributeError, expect, overwrite)
def test_overwrite_df(): data_path = os.path.join(os.path.dirname(__file__), 'data', '3eiy.pdb') pdb = PandasPdb().read_pdb(data_path) def overwrite(): pdb.df = 'bla' expect = ('Please use `PandasPdb._df = ... ` instead\n' 'of `PandasPdb.df = ... ` if you are sure that\n' 'you want to overwrite the `df` attribute.') assert_raises(AttributeError, expect, overwrite)
def test__read_pdb_raises(): """Test private _read_pdb: Test if ValueError is raised for wrong file formats.""" expect = ('Wrong file format; allowed file formats' ' are .pdb and .pdb.gz.') def run_code_1(): PandasPdb()._read_pdb("protein.mol2") assert_raises(ValueError, expect, run_code_1) def run_code_2(): PandasPdb()._read_pdb("protein.mol2.gz") assert_raises(ValueError, expect, run_code_2)