Add helpers to launch_pytest for checking stdout and stderr of launched processes
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
Direzione di ricerca
Inizia confrontando launch_pytest/test/launch_pytest/examples/pytest_hello_world.py con launch_testing/asserts/assert_output.py e launch_testing/event_handlers/stdout_ready_listener.py. Studia come launch_pytest possa osservare lo standard output e lo standard error di un processo quando i test non mantengono le azioni del processo, incluso il caso di un launch Gazebo annidato. Il risultato finale dovrebbe fornire helper o fixture documentati, con test che coprano l’output e gli errori attesi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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!
- Lingua principale
- Python
- Stelle
- 156
- Fork
- 200
- Merge medio
- 2g 11h
- PR unite (30g)
- 11
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ros2/launch
-
Use a relative target for the `latest` log symlink so it survives different absolute mount paths (host/Docker)Forse già presa @Old-Ding l’ha presa 139 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
ros2/launch#978 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Add OpaqueFunction to list at docs.ros.orgForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertabug help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ros2/launch#826 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
I maintainer di solito rispondono entro 1 giorno
-
[launch_testing] pytest>8.1 dropped the legacy "path" argument from its internal hooks on humbleForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertabug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
ros2/launch#979 · 6 commenti ·
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 1 giorno
-
hive size:simple
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
backend enhancement priority:P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
geolens-io/geolens#4161 ·
I maintainer di solito rispondono entro 1 giorno