This commit is contained in:
Jianjie Liu (MAIDAP) 2021-01-28 11:15:20 -05:00
Родитель 5339c76d05
Коммит 0d45d80a76
3 изменённых файлов: 14 добавлений и 6 удалений

Просмотреть файл

@ -3,5 +3,6 @@ flake8-import-order
pytest
pytest-cov
pytest-mock
pytest-xdist[psutil]
pytest-lazy-fixture
tox

Просмотреть файл

@ -8,10 +8,14 @@ from genalog.text import alignment
from tests.unit.cases.text_alignment import ALIGNMENT_REGRESSION_TEST_CASES
from tests.unit.cases.text_alignment import PARSE_ALIGNMENT_REGRESSION_TEST_CASES
RANDOM_INT = randint(1, 100)
MOCK_ALIGNMENT_RESULT = [("X", "X", 0, 0, 1)]
@pytest.fixture(scope="function")
def random_num_gap_char():
return alignment.GAP_CHAR*randint(1, 100)
# Settup mock for third party library call
@pytest.fixture
def mock_pairwise2_align(monkeypatch):
@ -152,19 +156,20 @@ def test__find_next_token(s, start, desired_output):
(" @@@t@@@ ", True),
("@@token@@", True),
(" @@token@@ ", True),
(f"t1{alignment.GAP_CHAR*RANDOM_INT}t2", True), # i.e. 't1@t2'
("t1{}t2", True), # i.e. 't1@t2' # injects arbitrary number of gap chars
# Invalid tokens (i.e. multiples of the GAP_CHAR)
("", False),
(" ", False),
("@@", False),
(" @@ ", False),
("\t\n@", False),
(alignment.GAP_CHAR * 1, False),
(alignment.GAP_CHAR * RANDOM_INT, False),
(f"\n\t {alignment.GAP_CHAR*RANDOM_INT} \n\t", False),
(alignment.GAP_CHAR, False),
("{}", False), # injects arbitrary number of gap chars
("\n\t {} \n\t", False), # injects arbitrary number of gap chars
],
)
def test__is_valid_token(token, desired_output):
def test__is_valid_token(random_num_gap_char, token, desired_output):
token = token.format(random_num_gap_char)
result = alignment._is_valid_token(token)
assert result == desired_output

Просмотреть файл

@ -47,6 +47,8 @@ testpaths =
addopts =
# reports all (except passed tests). See https://docs.pytest.org/en/latest/usage.html#detailed-summary-report
-ra
# use pytest-xdist to run tests in parallel
-n=auto
--cov-append --cov=genalog --cov-report=html --cov-report=term-missing --cov-report=xml --junitxml=junit/test-results.xml