-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update tests & constrain behavior in various ways. (#54)
* require that Record objects have name, sequence * new file for Record-specific tests * remove 'quality' if set to None
- Loading branch information
Showing
5 changed files
with
72 additions
and
9 deletions.
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from __future__ import absolute_import, unicode_literals, print_function | ||
from screed import Record | ||
import pytest | ||
|
||
|
||
@pytest.mark.xfail(raises=TypeError) | ||
def test_create_noname(): | ||
r = Record(sequence='ATGGAC') | ||
|
||
|
||
@pytest.mark.xfail(raises=TypeError) | ||
def test_create_noseq(): | ||
r = Record(name='somename') | ||
|
||
|
||
def test_create_quality_none(): | ||
r = Record(name='foo', sequence='ATGACG', quality=None) | ||
assert not hasattr(r, 'quality') | ||
|
||
|
||
def test_len(): | ||
r = Record(name='foo', sequence='ATGACG') | ||
assert len(r) == 6 | ||
|
||
|
||
# copied over from khmer tests/test_read_parsers.py | ||
def test_read_type_basic(): | ||
# Constructing without mandatory arguments should raise an exception | ||
with pytest.raises(TypeError): | ||
Record() | ||
|
||
name = "895:1:1:1246:14654 1:N:0:NNNNN" | ||
sequence = "ACGT" | ||
r = Record(name, sequence) | ||
|
||
assert r.name == name | ||
assert r.sequence == sequence | ||
assert not hasattr(r, 'quality'), x | ||
assert not hasattr(r, 'annotations'), x | ||
|
||
|
||
# copied over from khmer tests/test_read_parsers.py | ||
def test_read_type_attributes(): | ||
r = Record(sequence='ACGT', quality='good', name='1234', annotations='ann') | ||
assert r.sequence == 'ACGT' | ||
assert r.quality == 'good' | ||
assert r.name == '1234' | ||
assert r.annotations == 'ann' |