Skip to content

Commit

Permalink
Merge pull request #17 from microsoft/laserprec/xdist_tests
Browse files Browse the repository at this point in the history
Make test suite runnable in parallel. However, the CI pipeline does not run tests in parallel at this point.
  • Loading branch information
Jianjie Liu committed Jan 28, 2021
2 parents c90deed + 4bd9301 commit 9c858e6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ flake8-import-order
pytest
pytest-cov
pytest-mock
pytest-xdist[psutil]
pytest-lazy-fixture
tox
17 changes: 11 additions & 6 deletions tests/unit/text/test_alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@
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):
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 9c858e6

Please sign in to comment.