Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test of sample corpus to unittest suite #30

Merged
merged 4 commits into from
Feb 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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