Spaces:
Sleeping
Sleeping
File size: 1,765 Bytes
5760b44 f42ec01 5760b44 f42ec01 5760b44 b1106e6 5760b44 f42ec01 5760b44 35c0239 b1106e6 5760b44 f42ec01 5760b44 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
import pytest
from baseline import BaselineCommaFixer, _remove_punctuation
@pytest.fixture()
def baseline_fixer():
yield BaselineCommaFixer()
@pytest.mark.parametrize(
"test_input",
['',
'Hello world.',
'This test string should not have any commas inside it.',
'aAaalLL the.. weird?~! punctuation.should also . be kept-as is! Only fixing-commas.']
)
def test_fix_commas_leaves_correct_strings_unchanged(baseline_fixer, test_input):
result = baseline_fixer.fix_commas(s=test_input)
assert result == test_input
@pytest.mark.parametrize(
"test_input, expected",
[
['I, am.', 'I am.'],
['A complex clause however it misses a comma something else and a dot...?',
'A complex clause, however, it misses a comma, something else and a dot...?'],
['a pen an apple, \tand a pineapple!',
'a pen, an apple \tand a pineapple!'],
['Even newlines\ntabs\tand others get preserved.',
'Even newlines,\ntabs\tand others get preserved.'],
['I had no Creativity left, therefore, I come here, and write useless examples, for this test.',
'I had no Creativity left therefore, I come here and write useless examples for this test.']]
)
def test_fix_commas_fixes_incorrect_commas(baseline_fixer, test_input, expected):
result = baseline_fixer.fix_commas(s=test_input)
assert result == expected
@pytest.mark.parametrize(
"test_input, expected",
[['', ''],
['Hello world...', 'Hello world'],
['This: test - string should not, have any commas inside it...?',
'This test string should not have any commas inside it']]
)
def test__remove_punctuation(test_input, expected):
assert _remove_punctuation(test_input) == expected
|