Skip to content

Commit

Permalink
Merge pull request #30 from jenshnielsen/test_sample_corpus
Browse files Browse the repository at this point in the history
Add test of sample corpus to unittest suite
  • Loading branch information
Raquel Alegre committed Feb 24, 2016
2 parents 097ee5e + a466e3c commit c0bcb5a
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ script:
if [ "$JYTHON" == "true" ]; then
py.test
else
py.test --cov=pyoracc --cov-report xml
py.test --cov=pyoracc --cov-report xml --runslow
fi
- pep8 --exclude=parsetab.py .
Expand Down
6 changes: 6 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import pytest


def pytest_addoption(parser):
parser.addoption("--runslow", action="store_true",
help="run slow tests")
17 changes: 17 additions & 0 deletions pyoracc/test/fixtures/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@ def tiny_corpus():
return os.path.join(os.path.dirname(here), 'tiny_corpus')


def sample_corpus():
return os.path.join(os.path.dirname(here), 'sample_corpus')


def whole_corpus():
"""
Return the path to the full oracc corpus. This is not bundled with
pyoracc and only works if the environmental variable oracc_corpus_path
is set to the correct directory.
"""
try:
oracc_corpus_path = os.environ['oracc_corpus_path']
except KeyError:
oracc_corpus_path = None
return oracc_corpus_path


def anzu():
return sample_file("anzu")

Expand Down
28 changes: 27 additions & 1 deletion pyoracc/test/model/test_corpus.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,35 @@
import pytest

from ...model.corpus import Corpus

from ..fixtures import tiny_corpus
from ..fixtures import tiny_corpus, sample_corpus, whole_corpus


slow = pytest.mark.skipif(
not pytest.config.getoption("--runslow"),
reason="need --runslow option to run"
)


def test_tiny():
corpus = Corpus(source=tiny_corpus())
assert corpus.successes == 1
assert corpus.failures == 1


@slow
def test_sample():
corpus = Corpus(source=sample_corpus())
assert corpus.successes == 36
assert corpus.failures == 3


@pytest.mark.skipif(not whole_corpus(),
reason="Need to set oracc_corpus_path to point "
"to the whole corpus, which is not bundled with "
"pyoracc")
@slow
def test_whole():
corpus = Corpus(source=whole_corpus())
assert corpus.successes == 2474
assert corpus.failures == 394

0 comments on commit c0bcb5a

Please sign in to comment.