diff --git a/09-coap/test_spec09.py b/09-coap/test_spec09.py index 55fbc01..ab3251b 100644 --- a/09-coap/test_spec09.py +++ b/09-coap/test_spec09.py @@ -36,7 +36,7 @@ def coap_get( cmd = "coap get " if confirmable: cmd += "-c " - cmd += f"[{addr}]:{port:d} {resource}" + cmd += f"coap://[{addr}]:{port:d}{resource}" return self.cmd(cmd, timeout=timeout, async_=async_) diff --git a/conftest.py b/conftest.py index 62b7545..f40a3fc 100644 --- a/conftest.py +++ b/conftest.py @@ -6,6 +6,7 @@ See https://docs.pytest.org/en/stable/fixture.html#conftest-py-sharing-fixture-functions """ # noqa: E501 +import random import re import os import subprocess @@ -29,6 +30,7 @@ RIOTBASE = os.environ.get('RIOTBASE') RUNNING_CTRLS = [] RUNNING_EXPERIMENTS = [] +DEFAULT_PAN_ID = str(random.randint(0, 0xFFFD)) def pytest_addoption(parser): @@ -279,6 +281,10 @@ def nodes(local, request, boards, iotlab_site): for board in boards: if local or only_native or IoTLABExperiment.valid_board(board): env = {'BOARD': f'{board}'} + if only_native: + # XXX this does not work for a mix of native and non-native boards, + # but we do not have these in the release tests at the moment. + env["RIOT_TERMINAL"] = "native" else: env = { 'BOARD': IoTLABExperiment.board_from_iotlab_node(board), @@ -317,6 +323,12 @@ def update_env(node, modules=None, cflags=None, port=None, termflags=None, extra node.env.get('DOCKER_ENVIRONMENT_CMDLINE', '') + f" -e 'USEMODULE={node.env['USEMODULE']}'" ) + node.env['DEFAULT_PAN_ID'] = DEFAULT_PAN_ID + if os.environ.get('BUILD_IN_DOCKER', 0) == '1': + node.env['DOCKER_ENVIRONMENT_CMDLINE'] = ( + node.env.get('DOCKER_ENVIRONMENT_CMDLINE', '') + + f" -e 'DEFAULT_PAN_ID={node.env['DEFAULT_PAN_ID']}'" + ) if cflags is not None: node.env['CFLAGS'] = cflags if port is not None: diff --git a/requirements.txt b/requirements.txt index e71cc56..281ef21 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,4 +10,4 @@ pytest-cov pytest-rerunfailures riotctrl scapy -paho-mqtt +paho-mqtt<2 diff --git a/testutils/github.py b/testutils/github.py index d59761c..1b81f26 100644 --- a/testutils/github.py +++ b/testutils/github.py @@ -4,7 +4,7 @@ import urllib.parse from bs4 import BeautifulSoup -from github import Github, GithubException, InputFileContent +from github import Auth, Github, GithubException, InputFileContent from testutils.git import Git, GitError @@ -80,7 +80,7 @@ def get_github(): access_token = get_access_token() if not access_token: return None - return Github(access_token, base_url=API_URL) + return Github(auth=Auth.Token(access_token), base_url=API_URL) def get_repo(github): @@ -210,9 +210,9 @@ def create_comment(github, issue): def _generate_outcome_summary(pytest_report, task): # pylint: disable=C0209 return "{a_open}{outcome}{a_close}".format( - a_open=''.format(task["outcome_url"]) - if "outcome_url" in task - else '', + a_open=( + ''.format(task["outcome_url"]) if "outcome_url" in task else '' + ), outcome=pytest_report.outcome.upper(), a_close='' if "outcome_url" in task else '', ) diff --git a/testutils/tests/test_github.py b/testutils/tests/test_github.py index 824abe2..f6157dd 100644 --- a/testutils/tests/test_github.py +++ b/testutils/tests/test_github.py @@ -134,8 +134,7 @@ def __init__(self, issues): # pylint: disable=W0613 def get_issues(self, *args, **kwargs): - for issue in self.issues: - yield issue + yield from self.issues issues = [MockIssue(title) for title in issue_titles] repo = MockRepo(issues) @@ -983,9 +982,11 @@ def test_upload_results( monkeypatch.setattr( testutils.github, "get_results_gist", - lambda *args, **kwargs: (testutils.github.Git('.'), "", "the_gist_id") - if gist_created - else (None, None, None), + lambda *args, **kwargs: ( + (testutils.github.Git('.'), "", "the_gist_id") + if gist_created + else (None, None, None) + ), ) monkeypatch.setattr( testutils.github, "upload_result_content", lambda *args, **kwargs: head