Add helpers to launch_pytest for checking stdout and stderr of launched processes
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
Línea de trabajo
Comienza comparando launch_pytest/test/launch_pytest/examples/pytest_hello_world.py con launch_testing/asserts/assert_output.py y launch_testing/event_handlers/stdout_ready_listener.py. Investiga cómo launch_pytest puede observar la salida estándar y la salida de error estándar de un proceso cuando los tests no conservan las acciones del proceso, incluido el caso de un launch anidado de Gazebo. La solución terminada debe proporcionar helpers o fixtures documentados, con tests que cubran la salida y los errores esperados.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Feature request
Feature description
launch_testing provides several utilities for checking and waiting on process output, e.g.
It would be nice if we had similar facilities with launch_pytest.
We do have an example of checking the output of a process:
but it requires that the test has a reference to the action under test and that they can set the cached_output=True argument:
As a concrete example, I recently wanted to confirm that launching Gazebo Classic from a nested launch description would produce some expected output and no errors, however we don't have access to the process actions. Here's the existing test where are including the Gazebo launch description to test:
I did not find a simple way to check the output in this case, but maybe I've overlooked something.
Ultimately, I was able to write the test I wanted by registering a launch event handler on process IO and storing that in a list that can be checked in the test. Here's a test fixture I wrote that can be used by tests to check output on stderr:
@pytest.fixture()
def launch_capture_io():
class LaunchCaptureIO:
def __init__(self):
self._event = Event()
self.stderr = []
self.action = RegisterEventHandler(OnProcessIO(on_stderr=self._on_stderr))
def _on_stderr(self, io):
self.stderr.append(io.text.decode('utf-8'))
self._event.set()
def wait_for_stderr(self, *, timeout) -> bool:
result = self._event.wait(timeout)
self._event.clear()
return result
return LaunchCaptureIO()
Implementation considerations
Some options that might be worth investigating (I haven't thought too much about them yet):
- It would be nice if we could leverage any existing pytest features for io handling. I tried to use the built-in capsys feature, but I wasn't able to get it to work (I suspect this is due to launch creating child processes).
- Add a fixture like the one I presented above for the Gazebo test case (ie. use launch events to record process io).
- Instrument launch to be more amenable to testing process io. If we could easily identify processes of interest (e.g we have process matchers for events already) and configure them to cache their output from the test (e.g. maybe a launch configuration), then we could add helpers to query process io.
If anyone has other ideas or thoughts, happy to hear them!
- Lenguaje dominante
- Python
- Estrellas
- 156
- Forks
- 200
- Merge medio
- 2 d 11 h
- PR fusionados (30 d)
- 11
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la 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.
Más de ros2/launch
-
Use a relative target for the `latest` log symlink so it survives different absolute mount paths (host/Docker)Posiblemente ocupada @Old-Ding la tomó hace 139 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
ros2/launch#978 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Add OpaqueFunction to list at docs.ros.orgQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abiertobug help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
ros2/launch#826 · 4 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 30/100
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
Los mantenedores suelen responder en 1 día
-
[launch_testing] pytest>8.1 dropped the legacy "path" argument from its internal hooks on humblePosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertobug
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
ros2/launch#979 · 6 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de ros2/launch
Issues similares
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
Los mantenedores suelen responder en 1 día
-
hive size:simple
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
-
backend enhancement priority:P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
geolens-io/geolens#4161 ·
Los mantenedores suelen responder en 1 día