Skip to content

Commit

Permalink
switched to py.test, closes #12
Browse files Browse the repository at this point in the history
  • Loading branch information
simonvh committed Oct 22, 2017
1 parent c2d2f09 commit 447059d
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 27 deletions.
10 changes: 10 additions & 0 deletions conftest.py
@@ -0,0 +1,10 @@
import py.test

def pytest_addoption(parser):
parser.addoption('--slow', action='store_true', default=False,
help='Also run slow tests')

def pytest_runtest_setup(item):
"""Skip tests if they are marked as slow and --slow is not given"""
if getattr(item.obj, 'slow', None) and not item.config.getvalue('slow'):
py.test.skip('slow tests not requested')
2 changes: 1 addition & 1 deletion requirements.txt
@@ -1,4 +1,4 @@
nose
pytest
click
pyfaidx
norns>0.1.1
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
@@ -1,5 +1,5 @@
[metadata]
description-file = README.md

[nosetests]
[pytest]
attr=!slow
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -32,7 +32,7 @@
}

requires = [
'nose',
'pytest',
'click',
'pyfaidx',
'norns>0.1.1',
Expand Down
1 change: 0 additions & 1 deletion tests/test_annotation.py
@@ -1,4 +1,3 @@
from nose.tools import *
from tempfile import mkdtemp, NamedTemporaryFile
import genomepy
import shutil
Expand Down
9 changes: 1 addition & 8 deletions tests/test_gaps.py
@@ -1,4 +1,3 @@
from nose.tools import *
from tempfile import mkdtemp, NamedTemporaryFile
from genomepy.utils import generate_gap_bed
import shutil
Expand All @@ -11,13 +10,7 @@
except NameError:
FileNotFoundError = IOError

def setup():
pass

def teardown():
pass

def test_annotation():
def test_gaps():
infa = "tests/data/gap.fa"
outbed = "tests/data/gap.bed"

Expand Down
24 changes: 9 additions & 15 deletions tests/genomepy_tests.py → tests/test_genomepy.py
@@ -1,31 +1,26 @@
from nose.tools import *
from tempfile import mkdtemp, NamedTemporaryFile
import genomepy
import shutil
import pytest

# Python 2
try:
FileNotFoundError
except NameError:
FileNotFoundError = IOError

def setup():
print("SETUP!")

def teardown():
print("TEAR DOWN!")

def test_basic():
cfg = genomepy.functions.config
print(cfg)
assert 2 == len(cfg.keys())

@raises(FileNotFoundError)
def test_genome_dir_not_found():
genomepy.Genome("unknown", "unknown")
with pytest.raises(FileNotFoundError):
genomepy.Genome("unknown", "unknown")

@raises(FileNotFoundError)
def test_no_fasta_files():
genomepy.Genome("empty", "tests/data/genome")
with pytest.raises(FileNotFoundError):
genomepy.Genome("empty", "tests/data/genome")

def test_ucsc_genome():
"""Test UCSC.
Expand Down Expand Up @@ -66,6 +61,7 @@ def test_ncbi_genome():
assert str(seq).upper() == "TTTGCAACAGCTGCCGCAGTGTGACCGTTGTACTG"
shutil.rmtree(tmp)

@pytest.mark.slow
def test_ucsc_human():
"""Test UCSC.
Expand All @@ -79,6 +75,7 @@ def test_ucsc_human():
assert str(seq) == "CCTCCTCGCTCTCTT"
shutil.rmtree(tmp)

@pytest.mark.slow
def test_ensembl_human():
"""Test Ensembl.
Expand All @@ -92,6 +89,7 @@ def test_ensembl_human():
assert str(seq) == "CCTCCTCGCTCTCTT"
shutil.rmtree(tmp)

@pytest.mark.slow
def test_ncbi_human():
"""Test NCBI.
Expand Down Expand Up @@ -124,7 +122,3 @@ def test_regexp_filter():
fa = genomepy.utils.filter_fasta(
fname, tmpfa, regex=regex, v=True, force=True)
assert len(fa.keys()) == no_match

test_ncbi_human.slow = 1
test_ensembl_human.slow = 1
test_ucsc_human.slow = 1

0 comments on commit 447059d

Please sign in to comment.