Skip to content

add failure case tests for region parser - #86

Merged
vineetbansal merged 4 commits into
mainfrom
add-parsing-tests
Mar 30, 2026
Merged

add failure case tests for region parser#86
vineetbansal merged 4 commits into
mainfrom
add-parsing-tests

Conversation

@owenyu23

Copy link
Copy Markdown
Collaborator

Added the following case tests to test_parsing.py:

test_parse_unrecognized_extension: unrecognized file extension raises TypeError
test_parse_txt_empty_input: empty string input returns empty list
test_parse_unknown_gene_only: unknown gene is skipped
test_parse_unknown_and_real_genes: unknown gene is skipped, valid genes are still returned

Also added tests/data/test_invalid.csv as test data for the extension test

Comment thread tests/test_parsing.py Outdated

def test_parse_unrecognized_extension(data_folder):
file = os.path.join(data_folder, "test_invalid.csv")
try:

@vineetbansal vineetbansal Mar 29, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The standard way of testing of exceptions if a certain type are raised is to use with pytest.raises... Let's do that here.

Comment thread tests/test_parsing.py Outdated


def test_parse_unknown_gene_only():
file = "UNKNOWNGENE"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable name is a bit misleading, since its a direct str and not a file. However, since the variable is only ever used in the very next line, let's remove it altogether and just pass it in directly (in this test case and the next).

Comment thread tests/test_parsing.py Outdated

def test_parse_unknown_and_real_genes():
file = "RAD51\nUNKNOWNGENE\nchrII:5000-8000"
parser = region_parser(file, organism="sacCer3")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pass the string directly.

@vineetbansal

Copy link
Copy Markdown
Member

Thanks @owenyu23 - I'm running the tests locally since the CI still has billing issues. See my comments - all very minor.

@vineetbansal
vineetbansal merged commit 3e0b0b9 into main Mar 30, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants