Jacinto Velasco commited on
Commit ·
b2fe8e5
1
Parent(s): fec83ed
El resultado ya no desaparece al tocar otra cosa; cache y pruebas de uso
Browse files- app.py +75 -20
- pruebas_alumno.py +139 -0
app.py
CHANGED
|
@@ -73,6 +73,62 @@ def error_entrada(excepcion):
|
|
| 73 |
st.error("⚠️ %s" % excepcion)
|
| 74 |
|
| 75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
# --------------------------------------------------------------------------
|
| 77 |
# Barra lateral: ayuda de notación y ventana de dibujo
|
| 78 |
# --------------------------------------------------------------------------
|
|
@@ -165,14 +221,13 @@ with pestanas[0]:
|
|
| 165 |
with columna:
|
| 166 |
texto = st.text_input("Inecuación", value=elegido, key="ine")
|
| 167 |
|
| 168 |
-
if
|
| 169 |
try:
|
| 170 |
-
|
|
|
|
| 171 |
except ErrorDeEntrada as fallo:
|
| 172 |
error_entrada(fallo)
|
| 173 |
else:
|
| 174 |
-
with st.spinner("Resolviendo…"):
|
| 175 |
-
res = inecuaciones.resuelve(relacion)
|
| 176 |
|
| 177 |
for numero, titulo, cuerpo, comentario, clave in res.pasos:
|
| 178 |
st.subheader("%d. %s" % (numero, titulo))
|
|
@@ -269,14 +324,13 @@ with pestanas[1]:
|
|
| 269 |
with columna:
|
| 270 |
texto = st.text_input("Ecuación o inecuación", value=elegido, key="abs")
|
| 271 |
|
| 272 |
-
if
|
| 273 |
try:
|
| 274 |
-
|
|
|
|
| 275 |
except ErrorDeEntrada as fallo:
|
| 276 |
error_entrada(fallo)
|
| 277 |
else:
|
| 278 |
-
with st.spinner("Abriendo los casos…"):
|
| 279 |
-
res = absolutos.resuelve(relacion)
|
| 280 |
|
| 281 |
if res.aviso:
|
| 282 |
st.info(res.aviso)
|
|
@@ -323,7 +377,7 @@ with pestanas[1]:
|
|
| 323 |
st.divider()
|
| 324 |
st.subheader("Escribir una función con barras como función a trozos")
|
| 325 |
texto_f = st.text_input("Función", value="|x - 1| + |x + 2|", key="abs_f")
|
| 326 |
-
if
|
| 327 |
try:
|
| 328 |
funcion = lee_funcion(texto_f)
|
| 329 |
except ErrorDeEntrada as fallo:
|
|
@@ -387,15 +441,15 @@ with pestanas[2]:
|
|
| 387 |
help="Un número, una constante (pi, e, 1/2) o el infinito: "
|
| 388 |
"escribe oo o -oo.")
|
| 389 |
|
| 390 |
-
if
|
| 391 |
try:
|
| 392 |
funcion = lee_funcion(texto_f)
|
| 393 |
punto = lee_numero(punto_texto, "el punto")
|
|
|
|
|
|
|
| 394 |
except ErrorDeEntrada as fallo:
|
| 395 |
error_entrada(fallo)
|
| 396 |
else:
|
| 397 |
-
with st.spinner("Calculando…"):
|
| 398 |
-
est = limites.estudia(funcion, punto)
|
| 399 |
|
| 400 |
st.latex(r"\lim_{x \to %s} %s"
|
| 401 |
% (limites.punto_tex(punto), tex(funcion)))
|
|
@@ -528,7 +582,7 @@ with pestanas[3]:
|
|
| 528 |
"Punto a estudiar", value="0", key="cont_a",
|
| 529 |
help="Un número, o una constante como pi, e, 1/2, raiz(2).")
|
| 530 |
|
| 531 |
-
if
|
| 532 |
try:
|
| 533 |
punto = lee_numero(punto_texto, "el punto")
|
| 534 |
except ErrorDeEntrada as fallo:
|
|
@@ -600,7 +654,7 @@ with pestanas[3]:
|
|
| 600 |
))
|
| 601 |
|
| 602 |
st.divider()
|
| 603 |
-
if
|
| 604 |
with st.spinner("Barriendo la recta real…"):
|
| 605 |
revision = continuidad.revisa_todos(funcion)
|
| 606 |
if not revision:
|
|
@@ -659,15 +713,16 @@ with pestanas[4]:
|
|
| 659 |
punto_texto = st.text_input("en x =", value="0", key="rep_a",
|
| 660 |
disabled=not pide_tangente)
|
| 661 |
|
| 662 |
-
if
|
| 663 |
try:
|
| 664 |
funcion = lee_funcion(texto_f)
|
| 665 |
punto = lee_numero(punto_texto, "el punto") if pide_tangente else None
|
|
|
|
|
|
|
|
|
|
| 666 |
except ErrorDeEntrada as fallo:
|
| 667 |
error_entrada(fallo)
|
| 668 |
else:
|
| 669 |
-
with st.spinner("Haciendo el estudio completo…"):
|
| 670 |
-
est = representacion.estudia(funcion, punto)
|
| 671 |
|
| 672 |
st.latex(r"f(x) = %s" % tex(funcion))
|
| 673 |
|
|
@@ -849,14 +904,14 @@ with pestanas[5]:
|
|
| 849 |
orden = st.slider("Calcular además las derivadas sucesivas hasta el orden",
|
| 850 |
min_value=1, max_value=5, value=1, key="der_orden")
|
| 851 |
|
| 852 |
-
if
|
| 853 |
try:
|
| 854 |
funcion = lee_funcion(texto_f)
|
|
|
|
|
|
|
| 855 |
except ErrorDeEntrada as fallo:
|
| 856 |
error_entrada(fallo)
|
| 857 |
else:
|
| 858 |
-
with st.spinner("Derivando…"):
|
| 859 |
-
pasos, derivada = derivadas.desarrollo(funcion)
|
| 860 |
|
| 861 |
st.latex(r"f(x) = %s" % tex(funcion))
|
| 862 |
st.subheader("Desarrollo")
|
|
|
|
| 73 |
st.error("⚠️ %s" % excepcion)
|
| 74 |
|
| 75 |
|
| 76 |
+
# --------------------------------------------------------------------------
|
| 77 |
+
# Caché
|
| 78 |
+
# --------------------------------------------------------------------------
|
| 79 |
+
# Ahora que el resultado sigue en pantalla, el script lo recalcula en cada
|
| 80 |
+
# pasada: cada vez que el alumno mueve la ventana de la gráfica o cambia de
|
| 81 |
+
# pestaña. Son décimas de segundo, pero se notan como un parpadeo. Con la caché
|
| 82 |
+
# solo se calcula la primera vez para cada entrada.
|
| 83 |
+
#
|
| 84 |
+
# La clave es el TEXTO que escribe el alumno, no la expresión de SymPy: las
|
| 85 |
+
# cadenas se comparan rápido y son lo que de verdad identifica la consulta.
|
| 86 |
+
@st.cache_resource(show_spinner=False, max_entries=200)
|
| 87 |
+
def resuelve_inecuacion(texto):
|
| 88 |
+
return inecuaciones.resuelve(lee_relacion(texto))
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
@st.cache_resource(show_spinner=False, max_entries=200)
|
| 92 |
+
def resuelve_absoluto(texto):
|
| 93 |
+
return absolutos.resuelve(lee_relacion(texto))
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
@st.cache_resource(show_spinner=False, max_entries=200)
|
| 97 |
+
def calcula_limite(texto, punto_texto):
|
| 98 |
+
return limites.estudia(lee_funcion(texto), lee_numero(punto_texto, "el punto"))
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
# La continuidad no se guarda en caché: tarda una centésima de segundo, y
|
| 102 |
+
# además su función puede venir de la tabla de ramas, que no es un simple
|
| 103 |
+
# texto con el que indexar.
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
@st.cache_resource(show_spinner=False, max_entries=200)
|
| 107 |
+
def estudia_funcion(texto, punto_texto):
|
| 108 |
+
punto = lee_numero(punto_texto, "el punto") if punto_texto else None
|
| 109 |
+
return representacion.estudia(lee_funcion(texto), punto)
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
@st.cache_resource(show_spinner=False, max_entries=200)
|
| 113 |
+
def deriva_paso_a_paso(texto):
|
| 114 |
+
return derivadas.desarrollo(lee_funcion(texto))
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
def pulsado(etiqueta, clave, **extra):
|
| 118 |
+
"""Botón cuyo resultado SIGUE EN PANTALLA tras tocar otra cosa.
|
| 119 |
+
|
| 120 |
+
st.button solo devuelve True en la pasada inmediatamente posterior al clic.
|
| 121 |
+
Si el resultado se pinta dentro de ese «if», basta con que el alumno mueva
|
| 122 |
+
la ventana de la gráfica o cambie de pestaña para que el script se vuelva a
|
| 123 |
+
ejecutar, el botón valga ya False y todo el desarrollo desaparezca de
|
| 124 |
+
golpe. Se anota el clic en la sesión y se responde también a esa marca.
|
| 125 |
+
"""
|
| 126 |
+
marca = "mostrar_" + clave
|
| 127 |
+
if st.button(etiqueta, key=clave, **extra):
|
| 128 |
+
st.session_state[marca] = True
|
| 129 |
+
return bool(st.session_state.get(marca))
|
| 130 |
+
|
| 131 |
+
|
| 132 |
# --------------------------------------------------------------------------
|
| 133 |
# Barra lateral: ayuda de notación y ventana de dibujo
|
| 134 |
# --------------------------------------------------------------------------
|
|
|
|
| 221 |
with columna:
|
| 222 |
texto = st.text_input("Inecuación", value=elegido, key="ine")
|
| 223 |
|
| 224 |
+
if pulsado("Resolver", "btn_ine", type="primary"):
|
| 225 |
try:
|
| 226 |
+
with st.spinner("Resolviendo…"):
|
| 227 |
+
res = resuelve_inecuacion(texto)
|
| 228 |
except ErrorDeEntrada as fallo:
|
| 229 |
error_entrada(fallo)
|
| 230 |
else:
|
|
|
|
|
|
|
| 231 |
|
| 232 |
for numero, titulo, cuerpo, comentario, clave in res.pasos:
|
| 233 |
st.subheader("%d. %s" % (numero, titulo))
|
|
|
|
| 324 |
with columna:
|
| 325 |
texto = st.text_input("Ecuación o inecuación", value=elegido, key="abs")
|
| 326 |
|
| 327 |
+
if pulsado("Resolver por casos", "btn_abs", type="primary"):
|
| 328 |
try:
|
| 329 |
+
with st.spinner("Abriendo los casos…"):
|
| 330 |
+
res = resuelve_absoluto(texto)
|
| 331 |
except ErrorDeEntrada as fallo:
|
| 332 |
error_entrada(fallo)
|
| 333 |
else:
|
|
|
|
|
|
|
| 334 |
|
| 335 |
if res.aviso:
|
| 336 |
st.info(res.aviso)
|
|
|
|
| 377 |
st.divider()
|
| 378 |
st.subheader("Escribir una función con barras como función a trozos")
|
| 379 |
texto_f = st.text_input("Función", value="|x - 1| + |x + 2|", key="abs_f")
|
| 380 |
+
if pulsado("Pasar a trozos y dibujar", "btn_abs_f"):
|
| 381 |
try:
|
| 382 |
funcion = lee_funcion(texto_f)
|
| 383 |
except ErrorDeEntrada as fallo:
|
|
|
|
| 441 |
help="Un número, una constante (pi, e, 1/2) o el infinito: "
|
| 442 |
"escribe oo o -oo.")
|
| 443 |
|
| 444 |
+
if pulsado("Calcular el límite", "btn_lim", type="primary"):
|
| 445 |
try:
|
| 446 |
funcion = lee_funcion(texto_f)
|
| 447 |
punto = lee_numero(punto_texto, "el punto")
|
| 448 |
+
with st.spinner("Calculando…"):
|
| 449 |
+
est = calcula_limite(texto_f, punto_texto)
|
| 450 |
except ErrorDeEntrada as fallo:
|
| 451 |
error_entrada(fallo)
|
| 452 |
else:
|
|
|
|
|
|
|
| 453 |
|
| 454 |
st.latex(r"\lim_{x \to %s} %s"
|
| 455 |
% (limites.punto_tex(punto), tex(funcion)))
|
|
|
|
| 582 |
"Punto a estudiar", value="0", key="cont_a",
|
| 583 |
help="Un número, o una constante como pi, e, 1/2, raiz(2).")
|
| 584 |
|
| 585 |
+
if pulsado("Estudiar el punto", "btn_cont", type="primary"):
|
| 586 |
try:
|
| 587 |
punto = lee_numero(punto_texto, "el punto")
|
| 588 |
except ErrorDeEntrada as fallo:
|
|
|
|
| 654 |
))
|
| 655 |
|
| 656 |
st.divider()
|
| 657 |
+
if pulsado("Buscar TODOS los puntos problemáticos", "btn_cont_todos"):
|
| 658 |
with st.spinner("Barriendo la recta real…"):
|
| 659 |
revision = continuidad.revisa_todos(funcion)
|
| 660 |
if not revision:
|
|
|
|
| 713 |
punto_texto = st.text_input("en x =", value="0", key="rep_a",
|
| 714 |
disabled=not pide_tangente)
|
| 715 |
|
| 716 |
+
if pulsado("Estudiar la función", "btn_rep", type="primary"):
|
| 717 |
try:
|
| 718 |
funcion = lee_funcion(texto_f)
|
| 719 |
punto = lee_numero(punto_texto, "el punto") if pide_tangente else None
|
| 720 |
+
with st.spinner("Haciendo el estudio completo…"):
|
| 721 |
+
est = estudia_funcion(texto_f,
|
| 722 |
+
punto_texto if pide_tangente else "")
|
| 723 |
except ErrorDeEntrada as fallo:
|
| 724 |
error_entrada(fallo)
|
| 725 |
else:
|
|
|
|
|
|
|
| 726 |
|
| 727 |
st.latex(r"f(x) = %s" % tex(funcion))
|
| 728 |
|
|
|
|
| 904 |
orden = st.slider("Calcular además las derivadas sucesivas hasta el orden",
|
| 905 |
min_value=1, max_value=5, value=1, key="der_orden")
|
| 906 |
|
| 907 |
+
if pulsado("Derivar paso a paso", "btn_der", type="primary"):
|
| 908 |
try:
|
| 909 |
funcion = lee_funcion(texto_f)
|
| 910 |
+
with st.spinner("Derivando…"):
|
| 911 |
+
pasos, derivada = deriva_paso_a_paso(texto_f)
|
| 912 |
except ErrorDeEntrada as fallo:
|
| 913 |
error_entrada(fallo)
|
| 914 |
else:
|
|
|
|
|
|
|
| 915 |
|
| 916 |
st.latex(r"f(x) = %s" % tex(funcion))
|
| 917 |
st.subheader("Desarrollo")
|
pruebas_alumno.py
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
"""
|
| 3 |
+
pruebas_alumno.py -- La aplicación puesta del lado del alumno.
|
| 4 |
+
|
| 5 |
+
No comprueba que las matemáticas estén bien (de eso van pruebas.py y
|
| 6 |
+
pruebas_ejercicios.py), sino que la aplicación se porta bien con quien la usa:
|
| 7 |
+
|
| 8 |
+
- el resultado SIGUE en pantalla al tocar otra cosa;
|
| 9 |
+
- una entrada mal escrita da un aviso claro, no una traza de error;
|
| 10 |
+
- cada pestaña funciona sin tirar la aplicación;
|
| 11 |
+
- nada tarda tanto como para parecer colgado.
|
| 12 |
+
|
| 13 |
+
python pruebas_alumno.py
|
| 14 |
+
"""
|
| 15 |
+
|
| 16 |
+
from __future__ import print_function
|
| 17 |
+
|
| 18 |
+
import os
|
| 19 |
+
import sys
|
| 20 |
+
import time
|
| 21 |
+
|
| 22 |
+
AQUI = os.path.dirname(os.path.abspath(__file__))
|
| 23 |
+
os.chdir(AQUI)
|
| 24 |
+
sys.path.insert(0, AQUI)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
class _SalidaFiltrada(object):
|
| 28 |
+
"""Quita el aviso de streamlit sobre «ScriptRunContext», que es inofensivo."""
|
| 29 |
+
|
| 30 |
+
def __init__(self, envuelto):
|
| 31 |
+
self._envuelto = envuelto
|
| 32 |
+
|
| 33 |
+
def write(self, texto):
|
| 34 |
+
if "missing ScriptRunContext" in texto:
|
| 35 |
+
return len(texto)
|
| 36 |
+
return self._envuelto.write(texto)
|
| 37 |
+
|
| 38 |
+
def __getattr__(self, nombre):
|
| 39 |
+
return getattr(self._envuelto, nombre)
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
sys.stderr = _SalidaFiltrada(sys.stderr)
|
| 43 |
+
|
| 44 |
+
from streamlit.testing.v1 import AppTest # noqa: E402
|
| 45 |
+
|
| 46 |
+
ESPERA = 180
|
| 47 |
+
fallos = []
|
| 48 |
+
total = [0]
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def comprueba(descripcion, condicion, detalle=""):
|
| 52 |
+
total[0] += 1
|
| 53 |
+
if condicion:
|
| 54 |
+
print(" ok %s" % descripcion)
|
| 55 |
+
else:
|
| 56 |
+
fallos.append((descripcion, detalle))
|
| 57 |
+
print(" FALLA %s%s" % (descripcion, (" (%s)" % detalle) if detalle else ""))
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
def arranca():
|
| 61 |
+
app = AppTest.from_file(os.path.join(AQUI, "app.py"), default_timeout=ESPERA)
|
| 62 |
+
app.run()
|
| 63 |
+
return app
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
# ==========================================================================
|
| 67 |
+
print("\n--- El resultado no puede desaparecer al tocar otra cosa ---")
|
| 68 |
+
# ==========================================================================
|
| 69 |
+
CASOS = [
|
| 70 |
+
("inecuación", "ine", "btn_ine", "x^2 - 3x + 2 > 0", None, None),
|
| 71 |
+
("valor absoluto", "abs", "btn_abs", "|x| + |x - 3| <= 7", None, None),
|
| 72 |
+
("límite", "lim_f", "btn_lim", "raiz(x^2 + x) - x", "lim_a", "oo"),
|
| 73 |
+
("continuidad", "cont_f", "btn_cont", "(x^2 - 1)/(x - 1)", "cont_a", "1"),
|
| 74 |
+
("representación", "rep_f", "btn_rep", "(x^2 + 1)/(x - 1)", None, None),
|
| 75 |
+
("derivadas", "der_f", "btn_der", "x^3*sen(x)", None, None),
|
| 76 |
+
]
|
| 77 |
+
|
| 78 |
+
for nombre, clave, boton, valor, clave2, valor2 in CASOS:
|
| 79 |
+
app = arranca()
|
| 80 |
+
app.text_input(key=clave).set_value(valor)
|
| 81 |
+
if clave2:
|
| 82 |
+
app.text_input(key=clave2).set_value(valor2)
|
| 83 |
+
app.button(key=boton).click().run()
|
| 84 |
+
antes = len(app.subheader) + len(app.latex)
|
| 85 |
+
# el alumno mueve la ventana de la gráfica
|
| 86 |
+
app.number_input[0].set_value(-5.0).run()
|
| 87 |
+
despues = len(app.subheader) + len(app.latex)
|
| 88 |
+
comprueba("%s: el desarrollo sigue en pantalla" % nombre,
|
| 89 |
+
despues >= antes and antes > 0,
|
| 90 |
+
"antes %d elementos, despues %d" % (antes, despues))
|
| 91 |
+
|
| 92 |
+
# ==========================================================================
|
| 93 |
+
print("\n--- Entradas mal escritas: aviso claro, nunca una traza ---")
|
| 94 |
+
# ==========================================================================
|
| 95 |
+
MALAS = [
|
| 96 |
+
("ine", "btn_ine", "x^2 +", "inecuación sin terminar"),
|
| 97 |
+
("ine", "btn_ine", "x^2 - 1", "inecuación sin signo de comparación"),
|
| 98 |
+
("ine", "btn_ine", "x + y > 0", "dos letras distintas"),
|
| 99 |
+
("abs", "btn_abs", "|x - 1", "barra sin cerrar"),
|
| 100 |
+
("lim_f", "btn_lim", "sen(", "paréntesis sin cerrar"),
|
| 101 |
+
("rep_f", "btn_rep", "", "campo vacío"),
|
| 102 |
+
("der_f", "btn_der", "((x+1)", "paréntesis descuadrados"),
|
| 103 |
+
]
|
| 104 |
+
|
| 105 |
+
for clave, boton, valor, descripcion in MALAS:
|
| 106 |
+
app = arranca()
|
| 107 |
+
app.text_input(key=clave).set_value(valor)
|
| 108 |
+
app.button(key=boton).click().run()
|
| 109 |
+
sin_reventar = not app.exception
|
| 110 |
+
hay_aviso = len(app.error) > 0
|
| 111 |
+
comprueba("%s: avisa sin romperse" % descripcion,
|
| 112 |
+
sin_reventar and hay_aviso,
|
| 113 |
+
("excepción: %s" % app.exception[0].value) if app.exception
|
| 114 |
+
else "no ha mostrado ningún aviso")
|
| 115 |
+
|
| 116 |
+
# ==========================================================================
|
| 117 |
+
print("\n--- Nada debe tardar tanto como para parecer colgado ---")
|
| 118 |
+
# ==========================================================================
|
| 119 |
+
LIMITE_SEGUNDOS = 8.0
|
| 120 |
+
for nombre, clave, boton, valor, clave2, valor2 in CASOS:
|
| 121 |
+
app = arranca()
|
| 122 |
+
app.text_input(key=clave).set_value(valor)
|
| 123 |
+
if clave2:
|
| 124 |
+
app.text_input(key=clave2).set_value(valor2)
|
| 125 |
+
inicio = time.perf_counter()
|
| 126 |
+
app.button(key=boton).click().run()
|
| 127 |
+
tardanza = time.perf_counter() - inicio
|
| 128 |
+
comprueba("%s: responde en %.1f s" % (nombre, tardanza),
|
| 129 |
+
tardanza < LIMITE_SEGUNDOS and not app.exception,
|
| 130 |
+
"ha tardado %.1f s" % tardanza)
|
| 131 |
+
|
| 132 |
+
# ==========================================================================
|
| 133 |
+
print("\n" + "=" * 70)
|
| 134 |
+
if fallos:
|
| 135 |
+
print("%d de %d comprobaciones han fallado:\n" % (len(fallos), total[0]))
|
| 136 |
+
for descripcion, detalle in fallos:
|
| 137 |
+
print(" - %s\n %s" % (descripcion, detalle))
|
| 138 |
+
sys.exit(1)
|
| 139 |
+
print("Las %d comprobaciones han pasado." % total[0])
|