Skip to content

Commit

Permalink
Improve coverage inside test_lexemes.py
Browse files Browse the repository at this point in the history
  • Loading branch information
insolor committed Sep 8, 2023
1 parent f671847 commit ca88a94
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions tests/test_lexemes.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,7 @@ def test_has_proper_lexemes(lexeme, morph):
lexeme_words = get_lexeme_words(lexeme)

variants = _lexemes_for_word(lexeme_words[0], morph)
if lexeme_words not in variants:
variants_repr = "\n".join([" ".join(v) for v in variants])
assert False, f"{lexeme} not in \n{variants_repr}"
assert lexeme_words in variants, "{} not in \n{}".format(lexeme, "\n".join([" ".join(v) for v in variants]))


@pytest.mark.parametrize("lexeme", LEXEMES)
Expand Down Expand Up @@ -228,11 +226,8 @@ def test_full_lexemes(lexeme, morph):


def assert_has_full_lexeme(word, forms, morph):
for p in morph.parse(word):
lexeme_forms = [(f.word, str(f.tag)) for f in p.lexeme]
if lexeme_forms == forms:
return
raise AssertionError(f"Word {word} doesn't have lexeme {forms}")
assert any([(f.word, str(f.tag)) for f in p.lexeme] for p in morph.parse(word)), \
f"Word {word} doesn't have lexeme {forms}"


def _lexemes_for_word(word, morph):
Expand Down

0 comments on commit ca88a94

Please sign in to comment.