1
0
standardize_test_format/test/test_parsing.py
2025-03-03 10:08:55 +01:00

47 lines
1.0 KiB
Python

import re
import pytest
from standardize_test_format import (
PATTERN_DISPLAY_NAME,
PATTERN_DISPLAY_NAME_EXPRESSION,
PATTERN_JAVADOC,
)
VALID_JAVADOCS = [
'/** Hello World */',
'/** Hello\n * World */',
'/**\n * Hello World\n */',
]
VALID_DISPLAY_NAME_EXPRESSIONS = [
'"Hello"',
' "Hello" ',
'"Hello " + " World!"',
]
VALID_DISPLAY_NAMES = [
'@DisplayName("test")',
'@DisplayName( "test" )',
'@DisplayName(\n"test"\n)',
'@DisplayName("Hello " + " World!")',
'@DisplayName("Hello "\n+\n" World!")',
]
@pytest.mark.parametrize('text', VALID_JAVADOCS)
def test_javadoc_parsing(text: str):
assert re.match(PATTERN_JAVADOC, text) is not None
@pytest.mark.parametrize('text', VALID_DISPLAY_NAMES)
def test_display_name_parsing(text: str):
assert re.match(PATTERN_DISPLAY_NAME, text) is not None
@pytest.mark.parametrize('text', VALID_DISPLAY_NAME_EXPRESSIONS)
def test_display_name_expressions(text: str):
assert re.match(PATTERN_DISPLAY_NAME_EXPRESSION, text) is not None