def test_output_sans_desc(): read = FakeRecord() read.name = 'foo' read.sequence = 'ATCG' fileobj = BytesIO() write_fastx(read, fileobj) assert fileobj.getvalue().decode('utf-8') == '>foo\nATCG\n'
def test_output_two_reads(): fileobj = BytesIO() for i in range(2): read = FakeRecord() read.name = 'seq{}'.format(i) read.sequence = 'GATTACA' * (i + 1) write_fastx(read, fileobj) testoutput = '>seq0\nGATTACA\n>seq1\nGATTACAGATTACA\n' assert fileobj.getvalue().decode('utf-8') == testoutput
def test_output_with_desc(): read = FakeRecord() read.name = 'foo' read.description = 'bar' read.sequence = 'ATCG' read.quality = '####' fileobj = BytesIO() write_fastx(read, fileobj) assert fileobj.getvalue().decode('utf-8') == '@foo bar\nATCG\n+\n####\n'
def test_output_bad_mode(): read = FakeRecord() read.name = 'foo' read.description = 'bar' read.sequence = 'ATCG' read.quality = '####' fileobj = StringIO() with pytest.raises(AttributeError) as ae: write_fastx(read, fileobj) assert 'cannot call "write_fastx" on object' in str(ae)