Fix PyLint errors in tests

This commit is contained in:
Ivan Kravets
2020-08-17 12:56:57 +03:00
parent 2459e85c1d
commit 6f7fc638c7
22 changed files with 93 additions and 13 deletions

View File

@ -1,3 +1,6 @@
[REPORTS]
output-format=colorized
[MESSAGES CONTROL] [MESSAGES CONTROL]
disable= disable=
bad-continuation, bad-continuation,

View File

@ -1,5 +1,6 @@
lint: lint:
pylint --rcfile=./.pylintrc ./platformio pylint -j 6 --rcfile=./.pylintrc ./platformio ./tests
pylint -j 6 --rcfile=./.pylintrc ./tests
isort: isort:
isort -rc ./platformio isort -rc ./platformio

View File

@ -101,8 +101,6 @@ class PlatformBase( # pylint: disable=too-many-instance-attributes,too-many-pub
if spec.name not in packages: if spec.name not in packages:
packages[spec.name] = {} packages[spec.name] = {}
packages[spec.name].update(**options) packages[spec.name].update(**options)
print(13, packages)
return packages return packages
@property @property

13
tests/__init__.py Normal file
View File

@ -0,0 +1,13 @@
# Copyright (c) 2014-present PlatformIO <contact@platformio.org>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

View File

@ -0,0 +1,13 @@
# Copyright (c) 2014-present PlatformIO <contact@platformio.org>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

View File

@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# pylint: disable=global-statement,unused-argument
import json import json
import os import os
import random import random
@ -30,6 +32,7 @@ pytestmark = pytest.mark.skipif(
username = None username = None
email = None email = None
splited_email = None
firstname = None firstname = None
lastname = None lastname = None
password = None password = None
@ -43,7 +46,7 @@ team_description = None
def test_prepare(): def test_prepare():
global username, splited_email, email, firstname, lastname global username, email, splited_email, firstname, lastname
global password, orgname, display_name, second_username, teamname, team_description global password, orgname, display_name, second_username, teamname, team_description
username = "test-piocore-%s" % str(random.randint(0, 100000)) username = "test-piocore-%s" % str(random.randint(0, 100000))

View File

@ -40,7 +40,7 @@ def test_board_options(clirunner, validate_cliresult):
validate_cliresult(result) validate_cliresult(result)
search_result = json.loads(result.output) search_result = json.loads(result.output)
assert isinstance(search_result, list) assert isinstance(search_result, list)
assert len(search_result) assert search_result
platforms = [item["name"] for item in search_result] platforms = [item["name"] for item in search_result]
result = clirunner.invoke(cmd_boards, ["mbed", "--json-output"]) result = clirunner.invoke(cmd_boards, ["mbed", "--json-output"])

View File

@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# pylint: disable=redefined-outer-name
import json import json
import sys import sys
from os.path import isfile, join from os.path import isfile, join

View File

@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# pylint: disable=unused-argument
import json import json
import os import os

View File

@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# pylint: disable=line-too-long
import json import json
import re import re
@ -129,7 +131,9 @@ def test_global_install_repository(clirunner, validate_cliresult, isolated_pio_c
assert set(items1) >= set(items2) assert set(items1) >= set(items2)
def test_install_duplicates(clirunner, validate_cliresult, without_internet): def test_install_duplicates( # pylint: disable=unused-argument
clirunner, validate_cliresult, without_internet
):
# registry # registry
result = clirunner.invoke( result = clirunner.invoke(
cmd_lib, cmd_lib,
@ -231,7 +235,7 @@ def test_global_lib_update_check(clirunner, validate_cliresult):
result = clirunner.invoke(cmd_lib, ["-g", "update", "--dry-run", "--json-output"]) result = clirunner.invoke(cmd_lib, ["-g", "update", "--dry-run", "--json-output"])
validate_cliresult(result) validate_cliresult(result)
output = json.loads(result.output) output = json.loads(result.output)
assert set(["ESPAsyncTCP", "NeoPixelBus"]) == set([lib["name"] for lib in output]) assert set(["ESPAsyncTCP", "NeoPixelBus"]) == set(lib["name"] for lib in output)
def test_global_lib_update(clirunner, validate_cliresult): def test_global_lib_update(clirunner, validate_cliresult):

View File

@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# pylint: disable=unused-argument
import json import json
from platformio.commands import platform as cli_platform from platformio.commands import platform as cli_platform

View File

@ -33,6 +33,7 @@ def test_local_env():
) )
if result["returncode"] != 1: if result["returncode"] != 1:
pytest.fail(str(result)) pytest.fail(str(result))
# pylint: disable=unsupported-membership-test
assert all([s in result["err"] for s in ("PASSED", "IGNORED", "FAILED")]), result[ assert all([s in result["err"] for s in ("PASSED", "IGNORED", "FAILED")]), result[
"out" "out"
] ]

View File

@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# pylint: disable=unused-argument
from platformio.commands.update import cli as cmd_update from platformio.commands.update import cli as cmd_update

13
tests/ino2cpp/__init__.py Normal file
View File

@ -0,0 +1,13 @@
# Copyright (c) 2014-present PlatformIO <contact@platformio.org>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

13
tests/package/__init__.py Normal file
View File

@ -0,0 +1,13 @@
# Copyright (c) 2014-present PlatformIO <contact@platformio.org>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

View File

@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# pylint: disable=unused-argument
import os import os
import time import time

View File

@ -741,7 +741,7 @@ def test_examples_from_dir(tmpdir_factory):
return re.sub(r"[\\/]+", "/", path) return re.sub(r"[\\/]+", "/", path)
def _sort_examples(items): def _sort_examples(items):
for i, item in enumerate(items): for i, _ in enumerate(items):
items[i]["base"] = _to_unix_path(items[i]["base"]) items[i]["base"] = _to_unix_path(items[i]["base"])
items[i]["files"] = [_to_unix_path(f) for f in sorted(items[i]["files"])] items[i]["files"] = [_to_unix_path(f) for f in sorted(items[i]["files"])]
return sorted(items, key=lambda item: item["name"]) return sorted(items, key=lambda item: item["name"])

View File

@ -21,7 +21,8 @@ import pytest
from platformio import util from platformio import util
from platformio.compat import PY2 from platformio.compat import PY2
from platformio.managers.platform import PlatformFactory, PlatformManager from platformio.package.manager.platform import PlatformPackageManager
from platformio.platform.factory import PlatformFactory
from platformio.project.config import ProjectConfig from platformio.project.config import ProjectConfig
@ -34,8 +35,8 @@ def pytest_generate_tests(metafunc):
examples_dirs.append(normpath(join(dirname(__file__), "..", "examples"))) examples_dirs.append(normpath(join(dirname(__file__), "..", "examples")))
# dev/platforms # dev/platforms
for manifest in PlatformManager().get_installed(): for pkg in PlatformPackageManager().get_installed():
p = PlatformFactory.new(manifest["__pkg_dir"]) p = PlatformFactory.new(pkg)
examples_dir = join(p.get_dir(), "examples") examples_dir = join(p.get_dir(), "examples")
assert isdir(examples_dir) assert isdir(examples_dir)
examples_dirs.append(examples_dir) examples_dirs.append(examples_dir)

View File

@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# pylint: disable=unused-argument
import json import json
import os import os
import re import re

View File

@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# pylint: disable=unused-argument
import pytest import pytest
import requests import requests
@ -21,6 +23,7 @@ from platformio import exception, util
def test_platformio_cli(): def test_platformio_cli():
result = util.exec_command(["pio", "--help"]) result = util.exec_command(["pio", "--help"])
assert result["returncode"] == 0 assert result["returncode"] == 0
# pylint: disable=unsupported-membership-test
assert "Usage: pio [OPTIONS] COMMAND [ARGS]..." in result["out"] assert "Usage: pio [OPTIONS] COMMAND [ARGS]..." in result["out"]

View File

@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# pylint: disable=redefined-outer-name
import os import os
import pytest import pytest
@ -345,7 +347,7 @@ board = myboard
["check_types", [("float_option", 13.99), ("bool_option", True)]], ["check_types", [("float_option", 13.99), ("bool_option", True)]],
] ]
) )
config.get("platformio", "extra_configs") == "extra.ini" assert config.get("platformio", "extra_configs") == ["extra.ini"]
config.remove_section("platformio") config.remove_section("platformio")
assert config.as_tuple() == [ assert config.as_tuple() == [
("env:myenv", [("board", "myboard"), ("framework", ["espidf", "arduino"])]), ("env:myenv", [("board", "myboard"), ("framework", ["espidf", "arduino"])]),

View File

@ -31,7 +31,7 @@ commands =
[testenv:lint] [testenv:lint]
commands = commands =
{envpython} --version {envpython} --version
pylint --rcfile=./.pylintrc ./platformio pylint --rcfile=./.pylintrc ./platformio ./tests
[testenv:testcore] [testenv:testcore]
commands = commands =