1
0
standardize_test_format/test/test_standardize.py
Jon Michael Aanes 55cc962665
Some checks failed
Run Python tests (through Pytest) / Test (push) Failing after 22s
Verify Python project can be installed, loaded and have version checked / Test (push) Successful in 21s
fixing regex tests v2
2025-04-15 10:55:27 +02:00

159 lines
3.7 KiB
Python

import pytest
from standardize_test_format import NamingScheme, standardize_java_text, Config, TEST_PATTERN
INPUT_1 = """
package test;
@Test
@DisplayName("Invocations fail with callers without required permissions")
public void selectInvocationWithoutPermission() { }
"""
OUTPUT_1 = """
package test;
import org.junit.jupiter.api.DisplayName;
@Test
@DisplayName("Invocations fail with callers without required permissions")
public void invocationsFailWithCallersWithoutRequiredPermissions() { }
"""
INPUT_2 = """
package test;
/** Invocations fail with callers without required permissions. */
@Test
public void selectInvocationWithoutPermission() { }
"""
OUTPUT_2 = """
package test;
import org.junit.jupiter.api.DisplayName;
@Test
@DisplayName("Invocations fail with callers without required permissions")
public void invocationsFailWithCallersWithoutRequiredPermissions() { }
"""
INPUT_3 = """
package test;
@Test
public void helloWorldTest(
"""
OUTPUT_3 = """
package test;
import org.junit.jupiter.api.DisplayName;
@Test
@DisplayName("Hello World Test")
public void helloWorld(
"""
INPUT_4 = """
package test;
/**
* Concat two produces a new array with the two input arrays joined together, with no separators.
*/
@Test
public void concatTwo()
"""
OUTPUT_4 = """
package test;
import org.junit.jupiter.api.DisplayName;
@Test
@DisplayName("Concat two produces a new array with the two input arrays joined together, with no separators")
public void concatTwoProducesNewArrayWithTwoInputArraysJoinedTogetherWithNoSeparators()
"""
INPUT_5 = """
package test;
/**
* {@link ZkBinderContextImpl} propagates a lot of fields directly from the underlying {@link
* ZkBinderContext}.
*/
@Test
public void propagate()
"""
INPUT_5B = """
package test;
@Test
@DisplayName(
"ZkBinderContextImpl propagates a lot of fields directly from the underlying ZkBinderContext")
public void zkBinderContextImplPropagatesLotOfFieldsDirectlyFromTheUnderlyingZkBinderContext()
"""
INPUT_5C = """
package test;
@Test
@DisplayName(
"ZkBinderContextImpl propagates a lot of "
+ "fields directly from "
+ "the underlying ZkBinderContext"
)
public void zkBinderContextImplPropagatesLotOfFieldsDirectlyFromTheUnderlyingZkBinderContext()
"""
INPUT_5D = """
package test;
@DisplayName(
"ZkBinderContextImpl propagates a lot of "
+ "fields directly from "
+ "the underlying ZkBinderContext"
)
@Test
public void zkBinderContextImplPropagatesLotOfFieldsDirectlyFromTheUnderlyingZkBinderContext()
"""
OUTPUT_5 = """
package test;
import org.junit.jupiter.api.DisplayName;
@Test
@DisplayName("ZkBinderContextImpl propagates a lot of fields directly from the underlying ZkBinderContext")
public void zkBinderContextImplPropagatesLotFieldsDirectlyFromUnderlyingZkBinderContext()
"""
JAVADOC_TO_DISPLAYNAME = [
(INPUT_1, OUTPUT_1),
(INPUT_2, OUTPUT_2),
(INPUT_3, OUTPUT_3),
(INPUT_4, OUTPUT_4),
(INPUT_5, OUTPUT_5),
(INPUT_5B, OUTPUT_5),
(INPUT_5C, OUTPUT_5),
(INPUT_5D, OUTPUT_5),
]
CONFIG = Config(
with_javadoc=False,
with_display_name=True,
only_for_javadoc = False,
only_for_display_name = False,
only_for_todo = False,
naming_scheme=NamingScheme.FROM_DESC,
)
@pytest.mark.parametrize(('inp','output'), JAVADOC_TO_DISPLAYNAME)
def test_javadoc_to_displayname(inp: str, output: str):
converted = standardize_java_text(inp.strip(), CONFIG)
assert converted == output.strip()
@pytest.mark.parametrize(('inp','output'), JAVADOC_TO_DISPLAYNAME)
def test_match_input(inp: str, output: str):
assert TEST_PATTERN.search(inp)
@pytest.mark.parametrize(('inp','output'), JAVADOC_TO_DISPLAYNAME)
def test_match_output(inp: str, output: str):
assert TEST_PATTERN.search(output)