Skip to content

Commit

Permalink
Refactor some test fixtures now that pytest forbids calling fixtures …
Browse files Browse the repository at this point in the history
…as functions directly
  • Loading branch information
standage committed Nov 16, 2018
1 parent 9f51024 commit dab6418
Showing 1 changed file with 29 additions and 16 deletions.
45 changes: 29 additions & 16 deletions kevlar/tests/test_readpair.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@
from kevlar.readpair import ReadPair


@pytest.fixture
def record1():
def record1fix():
return Record(
name='read1',
sequence='GCTGCACCGATGTACGCAAA',
annotations=[KmerOfInterest(5, 14, [15, 0, 0])],
)


@pytest.fixture
def record2():
def record2fix():
return Record(
name='read2',
sequence='ACGCAAAGCTATTTAAAACC',
Expand All @@ -35,6 +33,28 @@ def record2():
)


def record3fix():
# reverse complement of record2
return Record(
name='read3',
sequence='GGTTTTAAATAGCTTTGCGT',
annotations=[
KmerOfInterest(5, 1, [19, 1, 0]),
KmerOfInterest(5, 14, [15, 0, 0]),
],
)


@pytest.fixture
def record1():
return record1fix()


@pytest.fixture
def record2():
return record2fix()


@pytest.fixture
def record2a():
return Record(
Expand All @@ -50,14 +70,7 @@ def record2a():
@pytest.fixture
def record3():
# reverse complement of record2
return Record(
name='read3',
sequence='GGTTTTAAATAGCTTTGCGT',
annotations=[
KmerOfInterest(5, 1, [19, 1, 0]),
KmerOfInterest(5, 14, [15, 0, 0]),
],
)
return record3fix()


@pytest.fixture
Expand Down Expand Up @@ -162,10 +175,10 @@ def picorecord4():


@pytest.mark.parametrize('read1,read2,sameorientation', [
(record1(), record2(), True),
(record2(), record1(), True),
(record1(), record3(), False),
(record3(), record1(), False),
(record1fix(), record2fix(), True),
(record2fix(), record1fix(), True),
(record1fix(), record3fix(), False),
(record3fix(), record1fix(), False),
])
def test_basic(read1, read2, sameorientation):
"""Pair of reads sharing an interesting k-mer.
Expand Down

0 comments on commit dab6418

Please sign in to comment.