def test_directives(): data = dedent(""" ##directive1 example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . """) it = iterators._StringIterator(data) db = create_db(data, dbfn=':memory:', from_string=True, verbose=False) assert it.directives == db.directives == ['directive1 example'], (it.directives, db.directives)
def test_directives(): data = dedent(""" ##directive1 example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . """) it = iterators._StringIterator(data) db = create_db(data, dbfn=':memory:', from_string=True, verbose=False) assert it.directives == db.directives == ['directive1 example' ], (it.directives, db.directives)
def test_parser_from_string(): """ make sure from string and from file return identical results """ line = b"chr2L FlyBase exon 7529 8116 . + . Name=CG11023:1;Parent=FBtr0300689,FBtr0300690" tmp = tempfile.NamedTemporaryFile() tmp.write(line) tmp.seek(0) p1 = iterators._StringIterator( "chr2L FlyBase exon 7529 8116 . + . Name=CG11023:1;Parent=FBtr0300689,FBtr0300690" ) p2 = iterators._FileIterator(tmp.name) lines = list(zip(p1, p2)) assert len(lines) == 1 assert p1.current_item_number == p2.current_item_number == 0 assert lines[0][0] == lines[0][1]