Clean up line breaks in tests.

See https://github.com/jensengroup/propka-3.1/issues/43
This commit is contained in:
Nathan Baker
2020-05-25 20:35:54 -07:00
parent 2bb6cf6293
commit 36bea44a4d

View File

@@ -22,7 +22,8 @@ MAX_ERR_DECIMALS = 2
TEST_DIR = Path("tests") TEST_DIR = Path("tests")
# Location for test PDBs # Location for test PDBs
PDB_DIR = Path("pdb") PDB_DIR = Path("pdb")
# Location for results for comparing output (allow running from tests/ and ../tests/) # Location for results for comparing output (allow running from tests/ and
# ../tests/)
RESULTS_DIR = Path("tests/results") RESULTS_DIR = Path("tests/results")
if not RESULTS_DIR.is_dir(): if not RESULTS_DIR.is_dir():
_LOGGER.warning("Switching to sub-directory") _LOGGER.warning("Switching to sub-directory")
@@ -47,7 +48,8 @@ def get_test_dirs():
if test_path.is_dir(): if test_path.is_dir():
path_dict[key] = test_path path_dict[key] = test_path
else: else:
errstr = "Can't find %s test files in %s" % (key, [TEST_DIR / path, path]) errstr = ("Can't find %s test files in %s"
% (key, [TEST_DIR / path, path]))
raise FileNotFoundError(errstr) raise FileNotFoundError(errstr)
return path_dict return path_dict
@@ -63,11 +65,12 @@ def run_propka(options, pdb_path, tmp_path):
options += [str(pdb_path)] options += [str(pdb_path)]
args = propka.lib.loadOptions(options) args = propka.lib.loadOptions(options)
try: try:
_LOGGER.warning("Working in tmpdir %s because of PROPKA file output; need to fix this.", _LOGGER.warning("Working in tmpdir %s because of PROPKA file output; "
tmp_path) "need to fix this.", tmp_path)
cwd = Path.cwd() cwd = Path.cwd()
os.chdir(tmp_path) os.chdir(tmp_path)
molecule = propka.molecular_container.Molecular_container(str(pdb_path), args) molecule = propka.molecular_container.Molecular_container(
str(pdb_path), args)
molecule.calculate_pka() molecule.calculate_pka()
molecule.write_pka() molecule.write_pka()
finally: finally:
@@ -103,9 +106,11 @@ def compare_output(pdb, tmp_path, ref_path):
match = re.search(r'([0-9]+\.[0-9]+)', line) match = re.search(r'([0-9]+\.[0-9]+)', line)
value = float(match.group(0)) value = float(match.group(0))
test_data.append(value) test_data.append(value)
errstr = "Error exceeds maximum allowed value (%d decimal places)" % MAX_ERR_DECIMALS errstr = ("Error exceeds maximum allowed value (%d decimal places)"
assert_almost_equal(test_data, ref_data, decimal=MAX_ERR_DECIMALS, % MAX_ERR_DECIMALS)
err_msg=errstr, verbose=True) assert_almost_equal(
test_data, ref_data, decimal=MAX_ERR_DECIMALS, err_msg=errstr,
verbose=True)
@pytest.mark.parametrize("pdb, options", [ @pytest.mark.parametrize("pdb, options", [