Skip to content
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

Improve tests to cover raising of errors when reading structures #251

Open
ns-rse opened this issue Nov 7, 2023 · 0 comments
Open

Improve tests to cover raising of errors when reading structures #251

ns-rse opened this issue Nov 7, 2023 · 0 comments
Labels
tests Issues pertaining to tests

Comments

@ns-rse
Copy link
Collaborator

ns-rse commented Nov 7, 2023

Stemming from a PR review #249 the check that a UserError and ValueError are raised introduced to pgfinder/pgio.py (line 174)...

    # Check that all structures are followed by "|n" where n is one or more digits
    if not theo_masses_df["Inferred structure"].str.contains(r"\|\d+$").all():
        raise UserError(

Isn't tested according to CodeCov.

Should be relatively straight-forward to construct a test for this (and other checks if they're not already covered) by having a simple CSV without the |[1|2] construct and using the...

@pytest.mark.parameterize(
    "file,error", 
    [
     
   ("tests/resources/file1.csv", UserError),
     
   ("tests/resources/file2.csv", ValueError),
]
)
def test_exceptions(file: str, error) -> None:
    with pytest.raises(error)
        assert theo_masses_reader(file)

(or similar, bit of a rough hack/guess at the code).

Originally posted by @ns-rse in #249 (comment)

@ns-rse ns-rse added the tests Issues pertaining to tests label Nov 7, 2023
@ns-rse ns-rse changed the title Codecov is saying this eventuality isn't tested. Improve tests to cover raising of errors when reading structures Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Issues pertaining to tests
Projects
None yet
Development

No branches or pull requests

1 participant