Rewrite .test as .py
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 20.6k
- Forks
- 3.3k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
Many of us are using editors that handle Python code (syntax highlighting, symbol browsing). Would it be a good idea to restructure the .test data-files as Python files?
I've been musing about it for a while, so hear me out, then let me know if it's a stupid idea :)
Example:
-[case testFoo]
-s1: str = 42 # E: Incompatible types in assignment (expression has type "int", variable has type "str")
+def test_foo():
+ s1: str = 42 # E: Incompatible types in assignment (expression has type "int", variable has type "str")
To clarify, this wouldn't be true Python code, i.e. it won't be fed directly to CPython or Mypy; rather, it'll be a Python-flavored data file — perhaps parsed by AST (if feasible and performant), but where the function bodies are passed to the current machinery as text.
Extra qualifies like # flags: --strict-optional could be represented as decorators, e.g.
@flags('--strict-optional')
def test_foo():
...
[case testFoo-xfail] would become:
@pytest.mark.xfail
def test_foo():
...
[out] would become:
@expected_output("""
main:1: Incompatible types in assignment (expression has type "int", variable has type "str")
""")
def test_foo():
...
[file a.py] would become:
@testcase
def test_foo():
... # main goes here
@test_foo.file('a.py')
def test_foo():
... # a.py goes here
Benefits:
- First-class support in IDEs, e.g.
- The disarray of testcase options, sections and modifiers could be formalized in a Pythonic syntax and a module that would document them, e.g.
from mypy.testcase import expected_outputand then# mypy/testcase.py def expected_output(output: str) -> Testcase: """Documentation goes here""" ... - Can use some Python tooling like Black
- A more flexible representation than INI, while providing first-class editor experience (unlike, say, converting to YAML and putting the Python test cases into a multiline YAML block).
- More natural for newcomers?
Cons:
- Harder to implement?
- Confusing that it's Python but not really?
- Less natural to newcomers?
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comience con el formato de archivo de datos .test existente y la maquinaria actual que consume testcase bodies; compare ese camino con el análisis mediante AST de los Python-flavored files propuestos. Un resultado útil sería decidir sobre la viabilidad, la sintaxis para opciones, secciones y modificadores, y si el formato puede conservar el comportamiento actual de las pruebas.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- developer-experience, testing-qa
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100