Comments (6)
Hey, thanks, this is a very good idea! I think what you're proposing makes a lot of sense. Can you send a PR with a change to the docs and also selftest/conftest.py
for it? :)
I have one comment about the example you make:
import pytest
import tbot
def _interfaces():
with tbot.ctx.request(tbot.role.Board) as b:
return b.interfaces
@pytest.mark.parametrize("interface", _interfaces())
def test_interface(interface):
print(interface)
I don't think you should do a request()
here for collecting the available interfaces. This will try initializing the board, so potentially power it on only to power it off immediately after. A better way would be to do this:
def _interfaces():
board_cls = tbot.ctx.get_machine_class(tbot.role.Board)
return board_cls.interfaces
This will not attempt interacting with a real board instance and just retrive the "cold" data from the class definition.
from tbot.
I am working on the PR. Additionally I did some further testing:
I have one comment about the example you make:
import pytest import tbot def _interfaces(): with tbot.ctx.request(tbot.role.Board) as b: return b.interfaces @pytest.mark.parametrize("interface", _interfaces()) def test_interface(interface): print(interface)I don't think you should do a
request()
here for collecting the available interfaces. This will try initializing the board, so potentially power it on only to power it off immediately after.
This is a great hint I missed that since I am working on my local machine with the dummy setup and not the real lab.
A better way would be to do this:
def _interfaces(): board_cls = tbot.ctx.get_machine_class(tbot.role.Board) return board_cls.interfacesThis will not attempt interacting with a real board instance and just retrive the "cold" data from the class definition
Your proposed improvement works perfectly well, but it has a slight drawback. I can no longer use/implement the interfaces in the board with @property
since properties belong to an instance and not the class itself. But TBH since this is static information anyway I do not really care. So I went with the following instead, but this is rather off-topic:
from typing import Dict, Set
from tbot import role
from tbot.machine import board, connector
class DummyBoard(connector.SubprocessConnector, board.Board):
interfaces: Dict[str, Set[str]] = {
"interface": {"interface0", "interface1"},
}
More importantly I moved the config load step for tbot to an even earlier point in time, namely the pytest_configure hook.
This was done to make use of pytest-metadata (+ pytest-html) to read and print metadata from a Board, but the more important point IMO is what the pytest-doc has to say about the hook:
pytest_configure(config)
Allow plugins and conftest files to perform initial configuration.
This hook is called for every plugin and initial conftest file after command line options have been parsed.
After that, the hook is called for other conftest files as they are imported.
To me this sounds like the even more appropriate (and portable?) location (than pytest_sessionstart) for loading a configuration file. @Rahix What do you think?
from tbot.
Agreed, pytest_configure()
sounds better! 👍
from tbot.
@Rahix I forked and added the documentation for this. TBH I am uncertain what to do about selftest/conftest.py now.
I looked at it and as far as I understand the configuration for the testmachines is not loaded in any related way or am I misunderstanding something here?
from tbot.
Ah, you are right, the selftests do things a bit differently. In that case, ignore what I said, sorry!
from tbot.
Great, in that case I am going to open the PR
from tbot.
Related Issues (20)
- Possible bug when auto login is used on the device HOT 3
- Timeout error while trying to reach the login prompt of the serial port over Paramiko Labhost HOT 8
- test/py test-framework hangs on some tests HOT 2
- shutil error while copying( fifo_console_send, fifo_console_recv, fifo_commands) in py/tests/test_cleanup_build.py HOT 6
- test/py wrapper should support out-of-tree U-Boot builds
- Send arbitrary commands via uboot console HOT 2
- Unable to retrieve the value of crc32 command in uboot with exec0. HOT 2
- inconsistency with env attribute behavior HOT 1
- running a tool that requires sudo permission HOT 1
- When running tests via SSH connector and SSH connection breaks due to device crash TBot hangs waiting indefinitely for SSH HOT 3
- shell.copy() does not accept globs in source path HOT 2
- Base exception classed raised HOT 3
- newbot CLI cannot generate log files
- Continuously print console to stdout
- Memory leak in SubprocessChannelIO HOT 3
- Processes not being terminated after SSH connection HOT 6
- Display SSH connection errors
- Timeout when waiting for a temination of a subprocess is hardcoded HOT 3
- Weird power cycle recursion HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tbot.