Unverified Commit 3f2a944a authored by Silvano Cerza's avatar Silvano Cerza Committed by GitHub

[skip changelog] Add linting and formatting for Python scripts (#832)

* [skip changelog] Added Python linting and formatting

Python linting is done using flake8 and formatting with black.
A linting workflow will run any time a Python file is modified, a format
workflow instead can be triggered by commenting in a PR.
Taskfile has been updated with lint and format tasks.

* [skip changelog] Fixed all Python linting issues

* [skip changelog] Fix Python linting and removed format workflow
parent 86034870
# TODO: move this to pyproject.toml when supported: https://gitlab.com/pycqa/flake8/merge_requests/245
[flake8]
max-line-length = 120
ignore = E741
name: "Lints Python code"
on:
push:
branches:
- master
paths:
- "**.py"
- ".flake8"
pull_request:
paths:
- "**.py"
- ".flake8"
jobs:
python-linting:
name: "Lints Python code"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: Install Taskfile
uses: Arduino/actions/setup-taskfile@master
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Activate Python
uses: actions/setup-python@v1
with:
python-version: '3.8'
architecture: 'x64'
- name: Install Poetry
run: pip install poetry
- name: Lints Python files
run: task python:check
......@@ -43,6 +43,15 @@ jobs:
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Python
uses: actions/setup-python@v1
with:
python-version: "3.8"
architecture: "x64"
- name: Install Poetry
run: pip install poetry
- name: Check the code is good
run: task check
......@@ -65,16 +74,8 @@ jobs:
if: matrix.operating-system == 'ubuntu-latest'
run: task test-legacy
- name: Install Python
uses: actions/setup-python@v1
with:
python-version: '3.8'
architecture: 'x64'
- name: Run integration tests
run: |
pip install poetry
task test-integration
run: task test-integration
- name: Send unit tests coverage to Codecov
# Since secrets aren't available on forks, we only
......
......@@ -104,6 +104,19 @@ tasks:
- go vet {{ default .DEFAULT_TARGETS .TARGETS }}
- "'{{.GOLINTBIN}}' {{.GOLINTFLAGS}} {{ default .DEFAULT_TARGETS .TARGETS }}"
- task: i18n:check
- task: python:check
python:check:
desc: Linting for Python files
cmds:
- poetry install --no-root
- poetry run flake8
python:format:
desc: Automatically formats Python files
cmds:
- poetry install --no-root
- poetry run black .
check-legacy:
desc: Check fmt and lint for the `legacy` package
......
......@@ -154,6 +154,20 @@ task test-integration
This will automatically install the necessary dependencies, if not already installed, and run the integration tests automatically.
When editing any Python file in the project remember to run linting checks with:
```shell
task python:check
```
This will run `flake8` automatically and return any error in the code formatting, if not already installed it will also install integration tests dependencies.
In case of linting errors you should be able to solve most of them by automatically formatting with:
```shell
task python:format
```
## Working on docs
Documentation is provided to final users in form of static HTML content generated
......
......@@ -100,15 +100,11 @@ def main(test, dry, remote):
# version is the most recent
docs_version, alias = get_docs_version(repo.active_branch.name, rel_br_names)
if docs_version is None:
print(
f"Can't get version from current branch '{repo.active_branch}', skip docs generation"
)
print(f"Can't get version from current branch '{repo.active_branch}', skip docs generation")
return 0
# Taskfile args aren't regular args so we put everything in one string
cmd = (
f"task docs:publish DOCS_REMOTE={remote} DOCS_VERSION={docs_version} DOCS_ALIAS={alias}",
)
cmd = (f"task docs:publish DOCS_REMOTE={remote} DOCS_VERSION={docs_version} DOCS_ALIAS={alias}",)
if dry:
print(cmd)
......
This diff is collapsed.
......@@ -5,7 +5,7 @@ description = "Project used to run integration tests for the Arduino CLI"
authors = []
[tool.poetry.dependencies]
python = "^3.5"
python = "^3.8"
pytest = "5.3.4"
simplejson = "3.17.0"
semver = "2.9.0"
......@@ -15,6 +15,9 @@ prometheus-client = "0.7.1"
requests = "2.22.0"
pytest-timeout = "1.3.4"
invoke = "1.4.1"
flake8 = "^3.8.3"
black = { version = "^19.10b0", allow-prereleases = true }
[tool.flake8]
max-line-length = 120
[tool.black]
line-length = 120
target-version = ["py38"]
......@@ -46,6 +46,22 @@ pytest test_lib.py
pytest test_lib.py::test_list
```
## Linting and formatting
To run lint check from the project's root folder:
```shell
task python:check
```
This will run `flake8` automatically and return any error in the code formatting, if not already installed it will also install integration tests dependencies.
In case of linting errors you should be able to solve most of them by automatically formatting with:
```shell
task python:format
```
[0]: ../docs/CONTRIBUTING.md
[poetry-website]: https://python-poetry.org/
[poetry-docs]: https://python-poetry.org/docs/
......@@ -41,12 +41,12 @@ def data_dir(tmpdir_factory):
# 3) libraries requiring headers deep down the include path
# for example:
#
# from C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\A7\packages\arduino\hardware\mbed\1.1.4\cores\arduino/mbed/rtos/Thread.h:29,
# from C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\A7\packages\arduino\hardware\mbed\1.1.4\cores\arduino/mbed/rtos/rtos.h:28,
# from C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\A7\packages\arduino\hardware\mbed\1.1.4\cores\arduino/mbed/mbed.h:23,
# from C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\A7\packages\arduino\hardware\mbed\1.1.4\cores\arduino/Arduino.h:32,
# from C:\Users\RUNNER~1\AppData\Local\Temp\arduino-sketch-739B2B6DD21EB014317DA2A46062811B\sketch\magic_wand.ino.cpp:1:
##[error]c:\users\runneradmin\appdata\local\temp\pytest-of-runneradmin\pytest-0\a7\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\c++\7.2.1\new:39:10: fatal error: bits/c++config.h: No such file or directory
# from C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\A7\packages\arduino\hardware\mbed\1.1.4\cores\arduino/mbed/rtos/Thread.h:29, # noqa: E501
# from C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\A7\packages\arduino\hardware\mbed\1.1.4\cores\arduino/mbed/rtos/rtos.h:28, # noqa: E501
# from C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\A7\packages\arduino\hardware\mbed\1.1.4\cores\arduino/mbed/mbed.h:23, # noqa: E501
# from C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\A7\packages\arduino\hardware\mbed\1.1.4\cores\arduino/Arduino.h:32, # noqa: E501
# from C:\Users\RUNNER~1\AppData\Local\Temp\arduino-sketch-739B2B6DD21EB014317DA2A46062811B\sketch\magic_wand.ino.cpp:1: # noqa: E501
# [error]c:\users\runneradmin\appdata\local\temp\pytest-of-runneradmin\pytest-0\a7\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\c++\7.2.1\new:39:10: fatal error: bits/c++config.h: No such file or directory # noqa: E501
#
# due to the above on Windows we cut the tmp path straight to /tmp/xxxxxxxx
if platform.system() == "Windows":
......@@ -96,9 +96,7 @@ def run_command(pytestconfig, data_dir, downloads_dir, working_dir):
cli_full_line = "{} {}".format(cli_path, cmd_string)
run_context = Context()
with run_context.cd(working_dir):
return run_context.run(
cli_full_line, echo=False, hide=True, warn=True, env=env
)
return run_context.run(cli_full_line, echo=False, hide=True, warn=True, env=env)
return _run
......@@ -125,9 +123,7 @@ def daemon_runner(pytestconfig, data_dir, downloads_dir, working_dir):
run_context.cd(working_dir)
# Local Class is the implementation of a Runner abstract class
runner = Local(run_context)
runner.run(
cli_full_line, echo=False, hide=True, warn=True, env=env, asynchronous=True
)
runner.run(cli_full_line, echo=False, hide=True, warn=True, env=env, asynchronous=True)
# we block here until the test function using this fixture has returned
yield runner
......
......@@ -39,6 +39,7 @@ def test_board_listall(run_command):
assert result.ok
assert ["Board", "Name", "FQBN"] == result.stdout.splitlines()[0].strip().split()
def test_board_details(run_command):
gold_board_details = """
{
......@@ -391,7 +392,7 @@ def test_board_details(run_command):
}
]
}
"""
""" # noqa: E501
result = run_command("core update-index")
assert result.ok
# Download samd core pinned to 1.8.6
......
......@@ -70,9 +70,7 @@ def test_compile_with_simple_sketch(run_command, data_dir, working_dir):
"Compile {sketch} for {fqbn} started".format(sketch=sketch_path, fqbn=fqbn),
"Compile {sketch} for {fqbn} successful".format(sketch=sketch_name, fqbn=fqbn),
]
assert is_message_sequence_in_json_log_traces(
expected_trace_sequence, json_log_lines
)
assert is_message_sequence_in_json_log_traces(expected_trace_sequence, json_log_lines)
# Test the --output-dir flag with absolute path
target = os.path.join(data_dir, "test_dir")
......@@ -105,11 +103,7 @@ def test_output_flag_default_path(run_command, data_dir, working_dir):
assert result.ok
# Test the --output-dir flag defaulting to current working dir
result = run_command(
"compile -b {fqbn} {sketch_path} --output-dir test".format(
fqbn=fqbn, sketch_path=sketch_path
)
)
result = run_command("compile -b {fqbn} {sketch_path} --output-dir test".format(fqbn=fqbn, sketch_path=sketch_path))
assert result.ok
target = os.path.join(working_dir, "test")
assert os.path.exists(target) and os.path.isdir(target)
......@@ -138,9 +132,7 @@ def test_compile_with_sketch_with_symlink_selfloop(run_command, data_dir):
os.symlink(loop_file_path, loop_file_path)
# Build sketch for arduino:avr:uno
result = run_command(
"compile -b {fqbn} {sketch_path}".format(fqbn=fqbn, sketch_path=sketch_path)
)
result = run_command("compile -b {fqbn} {sketch_path}".format(fqbn=fqbn, sketch_path=sketch_path))
# The assertion is a bit relaxed in this case because win behaves differently from macOs and linux
# returning a different error detailed message
assert "Error during sketch processing" in result.stderr
......@@ -162,9 +154,7 @@ def test_compile_with_sketch_with_symlink_selfloop(run_command, data_dir):
os.symlink(loop_dir_path, loop_dir_symlink_path)
# Build sketch for arduino:avr:uno
result = run_command(
"compile -b {fqbn} {sketch_path}".format(fqbn=fqbn, sketch_path=sketch_path)
)
result = run_command("compile -b {fqbn} {sketch_path}".format(fqbn=fqbn, sketch_path=sketch_path))
# The assertion is a bit relaxed also in this case because macOS behaves differently from win and linux:
# the cli does not follow recursively the symlink til breaking
assert "Error during sketch processing" in result.stderr
......@@ -185,7 +175,7 @@ def test_compile_and_upload_combo(run_command, data_dir, detected_boards):
# Create a test sketch
sketch_name = "CompileAndUploadIntegrationTest"
sketch_path = os.path.join(data_dir, sketch_name)
sketch_main_file = os.path.join(sketch_path, sketch_name+".ino")
sketch_main_file = os.path.join(sketch_path, sketch_name + ".ino")
result = run_command("sketch new {}".format(sketch_path))
assert result.ok
assert "Sketch created in: {}".format(sketch_path) in result.stdout
......@@ -194,17 +184,12 @@ def test_compile_and_upload_combo(run_command, data_dir, detected_boards):
for board in detected_boards:
log_file_name = "{fqbn}-compile.log".format(fqbn=board.fqbn.replace(":", "-"))
log_file_path = os.path.join(data_dir, log_file_name)
command_log_flags = "--log-format json --log-file {} --log-level trace".format(
log_file_path
)
command_log_flags = "--log-format json --log-file {} --log-level trace".format(log_file_path)
def run_test(s):
result = run_command(
"compile -b {fqbn} --upload -p {address} {sketch_path} {log_flags}".format(
fqbn=board.fqbn,
address=board.address,
sketch_path=s,
log_flags=command_log_flags,
fqbn=board.fqbn, address=board.address, sketch_path=s, log_flags=command_log_flags,
)
)
assert result.ok
......@@ -213,22 +198,12 @@ def test_compile_and_upload_combo(run_command, data_dir, detected_boards):
log_json = open(log_file_path, "r")
json_log_lines = log_json.readlines()
expected_trace_sequence = [
"Compile {sketch} for {fqbn} started".format(
sketch=sketch_path, fqbn=board.fqbn
),
"Compile {sketch} for {fqbn} successful".format(
sketch=sketch_name, fqbn=board.fqbn
),
"Upload {sketch} on {fqbn} started".format(
sketch=sketch_path, fqbn=board.fqbn
),
"Upload {sketch} on {fqbn} successful".format(
sketch=sketch_name, fqbn=board.fqbn
),
"Compile {sketch} for {fqbn} started".format(sketch=sketch_path, fqbn=board.fqbn),
"Compile {sketch} for {fqbn} successful".format(sketch=sketch_name, fqbn=board.fqbn),
"Upload {sketch} on {fqbn} started".format(sketch=sketch_path, fqbn=board.fqbn),
"Upload {sketch} on {fqbn} successful".format(sketch=sketch_name, fqbn=board.fqbn),
]
assert is_message_sequence_in_json_log_traces(
expected_trace_sequence, json_log_lines
)
assert is_message_sequence_in_json_log_traces(expected_trace_sequence, json_log_lines)
run_test(sketch_path)
run_test(sketch_main_file)
......@@ -267,11 +242,7 @@ def test_compile_blacklisted_sketchname(run_command, data_dir):
assert "Sketch created in: {}".format(sketch_path) in result.stdout
# Build sketch for arduino:avr:uno
log_file_name = "compile.log"
log_file_path = os.path.join(data_dir, log_file_name)
result = run_command(
"compile -b {fqbn} {sketch_path}".format(fqbn=fqbn, sketch_path=sketch_path)
)
result = run_command("compile -b {fqbn} {sketch_path}".format(fqbn=fqbn, sketch_path=sketch_path))
assert result.ok
......@@ -290,27 +261,44 @@ def test_compile_without_precompiled_libraries(run_command, data_dir):
# Install pre-release version of Arduino_TensorFlowLite (will be officially released
# via lib manager after https://github.com/arduino/arduino-builder/issues/353 is in)
import zipfile
with zipfile.ZipFile("test/testdata/Arduino_TensorFlowLite.zip", 'r') as zip_ref:
with zipfile.ZipFile("test/testdata/Arduino_TensorFlowLite.zip", "r") as zip_ref:
zip_ref.extractall("{}/libraries/".format(data_dir))
result = run_command("lib install Arduino_LSM9DS1@1.1.0")
assert result.ok
result = run_command("compile -b arduino:mbed:nano33ble {}/libraries/Arduino_TensorFlowLite/examples/magic_wand/".format(data_dir))
result = run_command(
"compile -b arduino:mbed:nano33ble {}/libraries/Arduino_TensorFlowLite/examples/magic_wand/".format(data_dir)
)
assert result.ok
result = run_command("compile -b adafruit:samd:adafruit_feather_m4 {}/libraries/Arduino_TensorFlowLite/examples/magic_wand/".format(data_dir))
result = run_command(
"compile -b adafruit:samd:adafruit_feather_m4 {}/libraries/Arduino_TensorFlowLite/examples/magic_wand/".format(
data_dir
)
)
assert result.ok
# Non-precompiled version of Arduino_TensorflowLite
result = run_command("lib install Arduino_TensorflowLite@1.15.0-ALPHA")
assert result.ok
result = run_command("compile -b arduino:mbed:nano33ble {}/libraries/Arduino_TensorFlowLite/examples/magic_wand/".format(data_dir))
result = run_command(
"compile -b arduino:mbed:nano33ble {}/libraries/Arduino_TensorFlowLite/examples/magic_wand/".format(data_dir)
)
assert result.ok
result = run_command("compile -b adafruit:samd:adafruit_feather_m4 {}/libraries/Arduino_TensorFlowLite/examples/magic_wand/".format(data_dir))
result = run_command(
"compile -b adafruit:samd:adafruit_feather_m4 {}/libraries/Arduino_TensorFlowLite/examples/magic_wand/".format(
data_dir
)
)
assert result.ok
# Bosch sensor library
result = run_command("lib install \"BSEC Software Library@1.5.1474\"")
result = run_command('lib install "BSEC Software Library@1.5.1474"')
assert result.ok
result = run_command("compile -b arduino:samd:mkr1000 {}/libraries/BSEC_Software_Library/examples/basic/".format(data_dir))
result = run_command(
"compile -b arduino:samd:mkr1000 {}/libraries/BSEC_Software_Library/examples/basic/".format(data_dir)
)
assert result.ok
result = run_command("compile -b arduino:mbed:nano33ble {}/libraries/BSEC_Software_Library/examples/basic/".format(data_dir))
result = run_command(
"compile -b arduino:mbed:nano33ble {}/libraries/BSEC_Software_Library/examples/basic/".format(data_dir)
)
assert result.ok
......@@ -13,7 +13,6 @@
# software without disclosing the source code of your own applications. To purchase
# a commercial license, send an email to license@arduino.cc.
import pytest
def test_completion_no_args(run_command):
result = run_command("completion")
......@@ -21,6 +20,7 @@ def test_completion_no_args(run_command):
assert "Error: accepts 1 arg(s), received 0" in result.stderr
assert result.stdout == ""
def test_completion_bash(run_command):
result = run_command("completion bash")
assert result.ok
......@@ -28,6 +28,7 @@ def test_completion_bash(run_command):
assert "_arduino-cli_root_command()" in result.stdout
assert "__start_arduino-cli()" in result.stdout
def test_completion_zsh(run_command):
result = run_command("completion zsh")
assert result.ok
......@@ -35,6 +36,7 @@ def test_completion_zsh(run_command):
assert "#compdef _arduino-cli arduino-cli" in result.stdout
assert "function _arduino-cli" in result.stdout
def test_completion_fish(run_command):
result = run_command("completion fish")
assert result.ok
......@@ -42,22 +44,25 @@ def test_completion_fish(run_command):
assert "# fish completion for arduino-cli" in result.stdout
assert "function __arduino-cli_perform_completion" in result.stdout
def test_completion_bash_no_desc(run_command):
result = run_command("completion bash --no-descriptions")
assert not result.ok
assert result.stdout == ""
assert "Error: command description is not supported by bash" in result.stderr
def test_completion_zsh_no_desc(run_command):
result = run_command("completion zsh --no-descriptions")
assert not result.ok
assert result.stdout == ""
assert "Error: command description is not supported by zsh" in result.stderr
def test_completion_fish_no_desc(run_command):
result = run_command("completion fish --no-descriptions")
assert result.ok
assert result.stderr == ""
assert "# fish completion for arduino-cli" in result.stdout
assert "function __arduino-cli_perform_completion" in result.stdout
assert "__completeNoDesc" in result.stdout
\ No newline at end of file
assert "__completeNoDesc" in result.stdout
......@@ -17,8 +17,6 @@ import platform
import pytest
import simplejson as json
from .common import running_on_ci
def test_core_search(run_command):
url = "https://raw.githubusercontent.com/arduino/arduino-cli/master/test/testdata/test_index.json"
......@@ -32,16 +30,12 @@ def test_core_search(run_command):
data = json.loads(result.stdout)
assert 0 < len(data)
# additional URL
result = run_command(
"core search test_core --format json --additional-urls={}".format(url)
)
result = run_command("core search test_core --format json --additional-urls={}".format(url))
assert result.ok
data = json.loads(result.stdout)
assert 1 == len(data)
# show all versions
result = run_command(
"core search test_core --all --format json --additional-urls={}".format(url)
)
result = run_command("core search test_core --all --format json --additional-urls={}".format(url))
assert result.ok
data = json.loads(result.stdout)
assert 2 == len(data)
......@@ -106,8 +100,7 @@ def test_core_updateindex_invalid_url(run_command):
@pytest.mark.skipif(
platform.system() == "Windows",
reason="core fails with fatal error: bits/c++config.h: No such file or directory",
platform.system() == "Windows", reason="core fails with fatal error: bits/c++config.h: No such file or directory",
)
def test_core_install_esp32(run_command, data_dir):
# update index
......@@ -121,9 +114,7 @@ def test_core_install_esp32(run_command, data_dir):
assert run_command("compile -b esp32:esp32:esp32 {}".format(sketch_path))
# prevent regressions for https://github.com/arduino/arduino-cli/issues/163
assert os.path.exists(
os.path.join(
sketch_path, "build/esp32.esp32.esp32/test_core_install_esp32.ino.partitions.bin"
)
os.path.join(sketch_path, "build/esp32.esp32.esp32/test_core_install_esp32.ino.partitions.bin",)
)
......
......@@ -31,14 +31,14 @@ def test_telemetry_prometheus_endpoint(daemon_runner, data_dir):
inventory_file = os.path.join(data_dir, "inventory.yaml")
while not os.path.exists(inventory_file):
time.sleep(1)
with open(inventory_file, 'r') as stream:
with open(inventory_file, "r") as stream:
inventory = yaml.safe_load(stream)
# Check if :9090/metrics endpoint is alive,
# telemetry is enabled by default in daemon mode
s = requests.Session()
retries = Retry(total=3, backoff_factor=1, status_forcelist=[500, 502, 503, 504])
s.mount('http://', HTTPAdapter(max_retries=retries))
s.mount("http://", HTTPAdapter(max_retries=retries))
metrics = s.get("http://localhost:9090/metrics").text
family = next(text_string_to_metric_families(metrics))
sample = family.samples[0]
......
......@@ -63,18 +63,13 @@ def test_install(run_command):
# Test failing-install of library with wrong dependency
# (https://github.com/arduino/arduino-cli/issues/534)
result = run_command("lib install MD_Parola@3.2.0")
assert (
"Error resolving dependencies for MD_Parola@3.2.0: dependency 'MD_MAX72xx' is not available"
in result.stderr
)
assert "Error resolving dependencies for MD_Parola@3.2.0: dependency 'MD_MAX72xx' is not available" in result.stderr
def test_update_index(run_command):
result = run_command("lib update-index")
assert result.ok
assert (
"Updating index: library_index.json downloaded"
== result.stdout.splitlines()[-1].strip()
)
assert "Updating index: library_index.json downloaded" == result.stdout.splitlines()[-1].strip()
def test_uninstall(run_command):
......@@ -84,6 +79,7 @@ def test_uninstall(run_command):
result = run_command("lib uninstall {}".format(" ".join(libs)))
assert result.ok
def test_uninstall_spaces(run_command):
key = '"LiquidCrystal I2C"'
assert run_command("lib install {}".format(key))
......@@ -92,6 +88,7 @@ def test_uninstall_spaces(run_command):
assert result.ok
assert len(json.loads(result.stdout)) == 0
def test_lib_ops_caseinsensitive(run_command):
"""
This test is supposed to (un)install the following library,
......@@ -108,13 +105,14 @@ def test_lib_ops_caseinsensitive(run_command):
Types: Contributed
Versions: [1.0.0]
"""
key = 'pcm'
key = "pcm"
assert run_command("lib install {}".format(key))
assert run_command("lib uninstall {}".format(key))
result = run_command("lib list --format json")
assert result.ok
assert len(json.loads(result.stdout)) == 0
def test_search(run_command):
assert run_command("lib update-index")
......@@ -151,9 +149,7 @@ def test_search_paragraph(run_command):
within the index file.
"""
assert run_command("lib update-index")
result = run_command(
'lib search "A simple and efficient JSON library" --format json'
)
result = run_command('lib search "A simple and efficient JSON library" --format json')
assert result.ok
libs_json = json.loads(result.stdout)
assert 1 == len(libs_json.get("libraries"))
......@@ -86,6 +86,6 @@ def test_inventory_creation(run_command, data_dir):
# parse inventory file
inventory_file = os.path.join(data_dir, "inventory.yaml")
with open(inventory_file, 'r') as stream:
with open(inventory_file, "r") as stream:
inventory = yaml.safe_load(stream)
assert "installation" in inventory
......@@ -20,8 +20,10 @@ import pytest
from test.common import running_on_ci
@pytest.mark.skipif(running_on_ci() and platform.system() == "Windows",
reason="Test disabled on Github Actions Win VM until tmpdir inconsistent behavior bug is fixed")
@pytest.mark.skipif(
running_on_ci() and platform.system() == "Windows",
reason="Test disabled on Github Actions Win VM until tmpdir inconsistent behavior bug is fixed",
)
def test_sketch_new(run_command, working_dir):
# Create a test sketch in current directory
current_path = working_dir
......
......@@ -33,17 +33,9 @@ def test_upload(run_command, data_dir, detected_boards):
sketch_path = os.path.join(data_dir, "foo")
assert run_command("sketch new {}".format(sketch_path))
# Build sketch
assert run_command(
"compile -b {fqbn} {sketch_path}".format(
fqbn=board.fqbn, sketch_path=sketch_path
)
)
assert run_command("compile -b {fqbn} {sketch_path}".format(fqbn=board.fqbn, sketch_path=sketch_path))
# Upload without port must fail
result = run_command(
"upload -b {fqbn} {sketch_path}".format(
sketch_path=sketch_path, fqbn=board.fqbn, port=board.address
)
)
result = run_command("upload -b {fqbn} {sketch_path}".format(sketch_path=sketch_path, fqbn=board.fqbn))
assert result.failed
# Upload
assert run_command(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment