I’d like to setup a project for a robotframework library robotframework-xyz
providing library XyzLibrary
which is consistent with uv
(src/robotframework_xyz
) as well as the naming convention of RF libs (XyzLibrary
).
The project structure:
robotframework-xyz
.devcontainer/
devcontainer.json
atests/
xyz.robot
src/
robotframework_xyz/
__init__.py
The __init__.py
file contains the class XyzLibrary
.
The content of devcontainer.json
:
{
"features": {
"ghcr.io/jsburckhardt/devcontainer-features/uv:1": {}
},
"postCreateCommand": "bash -i -c 'uv sync'",
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"ms-python.debugpy",
"d-biehl.robotcode"
],
// https://code.visualstudio.com/docs/python/settings-reference
"settings": {
// https://code.visualstudio.com/docs/python/settings-reference#_general-python-settings
"python.terminal.activateEnvInCurrentTerminal": true,
"python.defaultInterpreterPath": "/workspaces/robotframework-xyz/.venv/bin/python",
"python.venvFolders": [
"/workspaces/robotframework-xyz/.venv"
],
"robotcode.robot.variables": {
"ROOT": "/workspaces/robotframework-xyz"
},
"robotcode.robot.pythonPath": [
".",
"./src/robotframework_xyz"
],
The content of pyproject.toml
:
# https://docs.astral.sh/uv/reference/settings/
[tool.uv.sources]
robotframework-yxz = { workspace = true }
# https://robotcode.io/03_reference/config
[tool.robot]
python-path = [".", "./src/robotframework_xyz"]
paths = ["atests"]
output-dir = "results"
The content of __init__.py
:
from typing import Protocol
from robot.api.deco import keyword
class SomeProtocol(Protocol):
def some_method():
...
class XyzLibrary(SomeProtocol):
def some_method(self, ...):
...
@keyword("Keyword '${a}'")
def some_keyword(self, a):
...
The content of xyz.robot
:
*** Settings ***
Library XyzLibrary
*** Test Cases ***
Some test
Keyword "Something"
In general RobotCode is working. But whatever I tried already results in an Importing test library 'XyzLibrary' failed: ModuleNotFoundError: No module named 'XyzLibrary'
or a
Import definition contains errors.robotcode(ImportContainsErrors)
__init__.py(1, 1): Library 'robotframework_xyz.XyzLibrary' expected at least 1 non-named argument, got 0.
Has someone already setup a library with this setup and can help out?