-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix tests - 3 out of 4 cases are failing #14
Comments
@bobleesj (remind myself in the notification box to describe the issue in detail) |
As of now, the code lacks unit tests. However, it does have a test function, primarily running the Here is the test function: @pytest.mark.parametrize("tm", test_map)
def test_nmf_mapping_code(tm, temp_dir, capsys):
data_dir = tm[0]
working_dir = Path(temp_dir)
os.chdir(working_dir)
main(args=data_dir)
out, err = capsys.readouterr()
assert out == tm[2]
results_dir = os.path.join(working_dir, "nmf_result")
os.chdir(results_dir)
expected_base = os.path.join(os.path.dirname(__file__), "output")
test_specific_dir = os.path.join(expected_base, tm[1])
for root, dirs, files in os.walk("."):
for file in files:
if file in os.listdir(test_specific_dir):
fn1 = os.path.join(results_dir, file)
with open(fn1, "r") as f:
actual = f.read()
fn2 = os.path.join(test_specific_dir, file)
with open(fn2, "r") as f:
expected = f.read()
assert expected == actual The arguments for test_map = [
([data_dir, "--xrange", "5,10"], "output_1", "Number of components: 3\n"),
([data_dir], "output_2", "Number of components: 3\n"),
([data_dir, "--xrange", "5,10", "12,15"], "output_3", "Number of components: 3\n"),
] ProblemThe print statement of the number of components does not match against what's expected > assert out == tm[2]
E AssertionError: assert 'Improvement ...ponents: 10\n' == 'Number of components: 3\n'
E
E + Improvement ratio of 1E-3 not met, attempting 1E-2...
E + Improvement ratio of 1E-2 not met. Inspect data and impose manual cutoff
E - Number of components: 3
E ? ^
E + Number of components: 10
E ? ^^
/Users/imac/Downloads/dev/bg/diffpy.nmf_mapping/tests/test_NMF_analysis_code.py:48: AssertionError
Proposed solution
|
we can probably junk this test but let's take the opportunity of populating a few tests. We don't usually test the arg parser anyway. |
For bookkeeping purposes, #32 this PR was created to refactor our existing test function, please carefully read the discussions provided in the PR before addressing this issue. |
Same as the title. We should do fix them while we have time for
Re-visit for cookiecutting after releasing other diffpy packages with higher priority #13
The text was updated successfully, but these errors were encountered: