[riot-notifications] [RIOT-OS/RIOT] dist/pythonlibs: provide unittest TestCase wrapper for testrunner (#10431)
notifications at github.com
Tue Nov 20 12:43:13 CET 2018
I would get it differently, the thing I did not wanted to do in my `pytest` PR, is to change the `testrunner` module as saying "if you rewrite everything then…" has low impact.
But my first step, if I allow myself to modify it, is to split the `run` function so that each part can be used alone. (so you do not need to re-use it directly).
In my `pytest` poc PR to write a `fixture` which is basically another way of doing the `setup`, `teardown`, I needed to duplicate everything from the `run` function. https://github.com/RIOT-OS/RIOT/compare/RIOT-OS:e0e02c0...cladmi:2291001#diff-85e19ffeb672d73150a8a8ae876c42a9R35
In python you cannot replace a function call by a `yield` and it is a known limitation.
With this, you can implement the `TestCase` with normal `setupClass`, `teardownClass` and even `setup` and `teardown` depending on your need.
Then your test implementation TestCase class would just inherit from it.
In all the time I wrote tests, I never needed to do this introspection with the `issubclass`, and I would not like to maintain it.
I used this as a base class a long time ago https://github.com/iot-lab/iot-lab-gateway/blob/344a3e166fff1af1c14fbf95c132ef1906251c7d/gateway_code/integration/test_integration_mock.py#L50-L89
Then running the test would only be to call the default `unittest.run` function or something.
I could propose something along those lines if you want.
And the second one, would be to write, not even in `testrunner` but in a normal `riotnode` package, a `Node` object with `start`, `stop`, `expect_`, other new functions.
As there is an object, you can subclass it (intelligently of course to be able to merge many class together), and then have a `RIOTShellNode` class.
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the notifications