-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix parse record error verbiage
- Loading branch information
Jeremy Myslinski
committed
Jun 24, 2024
1 parent
1d9a36e
commit 5f87a81
Showing
2 changed files
with
16 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,10 @@ | |
|
||
import io | ||
import sys | ||
import pytest | ||
|
||
from vcfpy import parser | ||
from vcfpy import exceptions | ||
|
||
__author__ = "Manuel Holtgrewe <[email protected]>" | ||
|
||
|
@@ -178,3 +180,16 @@ def test_missing_pass(recwarn): | |
RESULT = p.parse_next_record() | ||
assert str(RESULT) == EXPECTED | ||
assert list(recwarn) == [] | ||
|
||
|
||
def test_parse_line_invalid_number_of_fields(): | ||
"""Test parsing VCF file exception message""" | ||
HEADER = "##fileformat=VCFv4.2\n#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\n" | ||
LINES = "20\t1\t.\tC\tG\t.\tPASS\t.\tGT\n" | ||
EXPECTED = "The line contains an invalid number of fields. Was 9 but expected 8" | ||
p = parser.Parser(io.StringIO(HEADER + LINES), "<builtin>") | ||
p.parse_header() | ||
with pytest.raises(exceptions.InvalidRecordException) as record_error: | ||
p.parse_next_record() | ||
|
||
assert EXPECTED in str(record_error.value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters