Skip to content

Commit

Permalink
Merge pull request #35 from standage/testdata/open
Browse files Browse the repository at this point in the history
Add pkgdata function
  • Loading branch information
standage committed Dec 15, 2016
2 parents 44f0f89 + 1c2869d commit 4fde89f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
import versioneer


d = 'Genome annotation data analysis and management implemented in pure Python'
setup(name='tag',
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
description='Toolkit for genome annotation data analysis',
url='http://github.com/standage/tag',
description=d,
url='http://tag.readthedocs.io',
author='Daniel Standage',
author_email='daniel.standage@gmail.com',
license='BSD-3',
packages=['tag'],
tests_require=['pytest', 'pytest-cov', 'pep8'],
scripts=list(glob.glob('scripts/*.py')),
classifiers=[
'Development Status :: 4 - Beta',
Expand Down
5 changes: 5 additions & 0 deletions tag/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ def open(filename, mode):
return openfunc(filename, mode)


def pkgdata(filename):
fullpath = '{dir}/{fn}'.format(dir='tests/testdata/', fn=filename)
return open(fullpath, 'r')


def demo_feature():
gene = feature.Feature(
'contig1\tsnap\tgene\t1000\t7500\t.\t+\t.\tID=gene1'
Expand Down
6 changes: 3 additions & 3 deletions tests/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def test_feature_out_of_range():

def test_seqreg_dup():
"""Duplicated sequence-region pragma."""
infile = tag.open('tests/testdata/vcar-seqreg-dup.gff3.gz', 'r')
infile = tag.pkgdata('vcar-seqreg-dup.gff3.gz')
reader = GFF3Reader(instream=infile)
with pytest.raises(ValueError) as ve:
records = [r for r in reader]
Expand All @@ -202,12 +202,12 @@ def test_seqreg_dup():

def test_seqreg_outoforder():
"""sequence-region pragma declared after features on that sequence."""
infile = tag.open('tests/testdata/grape-cpgat-seqreg-after.gff3.gz', 'r')
infile = tag.pkgdata('grape-cpgat-seqreg-after.gff3.gz')
reader = GFF3Reader(instream=infile)
records = [r for r in reader]
assert len(records) == 5

infile = tag.open('tests/testdata/grape-cpgat-seqreg-after.gff3.gz', 'r')
infile = tag.pkgdata('grape-cpgat-seqreg-after.gff3.gz')
reader = GFF3Reader(instream=infile, assumesorted=True)
with pytest.raises(ValueError) as ve:
records = [r for r in reader]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_tag_open_read():
with pytest.raises(IOError):
fh = tag.open('tag/bogus.py', 'r')

fh = tag.open('tests/testdata/gzipdata.gff3.gz', 'r')
fh = tag.pkgdata('gzipdata.gff3.gz')
line = next(fh)
assert line == '##gff-version 3\n'

Expand Down

0 comments on commit 4fde89f

Please sign in to comment.