Permalink
Browse files

Updating pytests

  • Loading branch information...
betteridiot committed Sep 20, 2018
1 parent 19c7fc8 commit cbb5f056bea8079e4cbf65d90e09958bb9db57be
Showing with 19 additions and 8 deletions.
  1. +1 −2 .travis.yml
  2. +5 −5 bamnostic/bam.py
  3. +2 −1 pytest.ini
  4. +11 −0 tests/test_build.py
@@ -12,11 +12,9 @@ python:
- "pypy"
- "pypy3.5"
before_install:
- chmod +x .travis/push.sh
install:
install:
- git clone https://github.com/$TRAVIS_REPO_SLUG.git $TRAVIS_REPO_SLUG
- cd $TRAVIS_REPO_SLUG
@@ -26,4 +24,5 @@ install:
script:
- pytest --doctest-modules bamnostic/
- pytest
@@ -520,7 +520,7 @@ def fetch(self, contig=None, start=None, stop=None, region=None,
Examples:
>>> bam = bamnostic.AlignmentFile(bamnostic.example_bam, 'rb')
>>> next(bam.fetch('chr1', 1, 10)) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
>>> next(bam.fetch('chr1', 1, 100)) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
EAS56_57:6:190:289:82 ... MF:C:192
>>> next(bam.fetch('chr10', 1, 10))
@@ -660,10 +660,10 @@ def count(self, contig=None, start=None, stop=None, region=None,
Example:
>>> bam = bamnostic.AlignmentFile(bamnostic.example_bam, 'rb')
>>> bam.count('chr1', 1, 100)
3
2
>>> bam.count('chr1', 1, 100, read_callback='all')
2
1
>>> bam.count('chr10', 1, 10)
Traceback (most recent call last):
@@ -758,14 +758,14 @@ def count_coverage(self, contig=None, start=None, stop=None, region=None,
... print("array('{}', {})".format(arr.typecode, list(map(int, arr.tolist()))))
array('L', [0, 0, 0, 0, ..., 0, 0, 0, 0, 0])
array('L', [0, 0, 0, 0, ..., 0, 0, 0, 0, 0])
array('L', [1, 1, 2, 2, ..., 0, 14, 0, 14, 14])
array('L', [0, 0, 1, 1, ..., 0, 14, 0, 14, 14])
array('L', [0, 0, 0, 0, ..., 15, 0, 14, 0, 0])
>>> for arr in bam.count_coverage('chr1', 100, 150, quality_threshold=20, base_quality_threshold=25): # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
... print("array('{}', {})".format(arr.typecode, list(map(int, arr.tolist()))))
array('L', [0, 0, 0, 0, ..., 0, 0, 0, 0, 0])
array('L', [0, 0, 0, 0, ..., 0, 0, 0, 0, 0])
array('L', [1, 1, 2, 2, ..., 0, 14, 0, 13, 11])
array('L', [0, 0, 1, 1, ..., 0, 14, 0, 13, 11])
array('L', [0, 0, 0, 0, ..., 14, 0, 13, 0, 0])
"""
@@ -1,2 +1,3 @@
[pytest]
doctest_optionflags= NORMALIZE_WHITESPACE ALLOW_UNICODE ELLIPSIS ALLOW_BYTES
doctest_optionflags= NORMALIZE_WHITESPACE ALLOW_UNICODE ELLIPSIS ALLOW_BYTES
addopts = --doctest-modules
@@ -13,3 +13,14 @@ def test_first_read():
with bs.AlignmentFile(bs.example_bam, 'rb') as bam:
first_read = next(bam)
assert first_read.read_name == 'EAS56_57:6:190:289:82'
def test_check_index():
with bs.AlignmentFile(bs.example_bam) as bam:
with pytest.warns(UserWarning):
bam.check_index('not_a_file.bai')
def test_get_index():
with pytest.warns(UserWarning):
bam_no_bai = bs.AlignmentFile(bs.example_bam, index_filename='not_a_file.bai')

0 comments on commit cbb5f05

Please sign in to comment.