mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-29 17:47:14 +02:00
Cleanup tests
This commit is contained in:
2
Makefile
2
Makefile
@ -10,7 +10,7 @@ yapf:
|
||||
yapf --recursive --in-place platformio/
|
||||
|
||||
test:
|
||||
py.test -v -s tests --ignore tests/test_examples.py --ignore tests/test_pkgmanifest.py
|
||||
py.test -v -s -n 3 --dist=loadscope tests --ignore tests/test_examples.py --ignore tests/test_pkgmanifest.py
|
||||
|
||||
before-commit: isort yapf lint test
|
||||
|
||||
|
@ -97,10 +97,9 @@ class UndefinedPackageVersion(PlatformioException):
|
||||
|
||||
class PackageInstallError(PlatformioException):
|
||||
|
||||
MESSAGE = (
|
||||
"Could not install '{0}' with version requirements '{1}' "
|
||||
"for your system '{2}'.\n"
|
||||
"More details: http://bit.ly/faq-package-manager")
|
||||
MESSAGE = ("Could not install '{0}' with version requirements '{1}' "
|
||||
"for your system '{2}'.\n"
|
||||
"More details: http://bit.ly/faq-package-manager")
|
||||
|
||||
|
||||
class FDUnrecognizedStatusCode(PlatformioException):
|
||||
|
@ -45,7 +45,7 @@ def test_ci_lib_and_board(clirunner, validate_cliresult):
|
||||
example_dir = join("examples", "atmelavr", "arduino-external-libs")
|
||||
result = clirunner.invoke(cmd_ci, [
|
||||
join(example_dir, "lib", "OneWire", "examples", "DS2408_Switch",
|
||||
"DS2408_Switch.pde"), "-l", join(example_dir, "lib", "OneWire"),
|
||||
"-b", "uno"
|
||||
"DS2408_Switch.pde"), "-l",
|
||||
join(example_dir, "lib", "OneWire"), "-b", "uno"
|
||||
])
|
||||
validate_cliresult(result)
|
||||
|
@ -54,7 +54,7 @@ def test_init_duplicated_boards(clirunner, validate_cliresult, tmpdir):
|
||||
assert set(config.sections()) == set(["env:uno"])
|
||||
|
||||
|
||||
def test_init_ide_without_board(clirunner, validate_cliresult, tmpdir):
|
||||
def test_init_ide_without_board(clirunner, tmpdir):
|
||||
with tmpdir.as_cwd():
|
||||
result = clirunner.invoke(cmd_init, ["--ide", "atom"])
|
||||
assert result.exit_code == -1
|
||||
@ -67,13 +67,15 @@ def test_init_ide_atom(clirunner, validate_cliresult, tmpdir):
|
||||
cmd_init, ["--ide", "atom", "-b", "uno", "-b", "teensy31"])
|
||||
validate_cliresult(result)
|
||||
validate_pioproject(str(tmpdir))
|
||||
assert all([tmpdir.join(f).check()
|
||||
for f in (".clang_complete", ".gcc-flags.json")])
|
||||
assert all([
|
||||
tmpdir.join(f).check()
|
||||
for f in (".clang_complete", ".gcc-flags.json")
|
||||
])
|
||||
assert "arduinoavr" in tmpdir.join(".clang_complete").read()
|
||||
|
||||
# switch to NodeMCU
|
||||
result = clirunner.invoke(
|
||||
cmd_init, ["--ide", "atom", "-b", "nodemcuv2"])
|
||||
result = clirunner.invoke(cmd_init,
|
||||
["--ide", "atom", "-b", "nodemcuv2"])
|
||||
validate_cliresult(result)
|
||||
validate_pioproject(str(tmpdir))
|
||||
assert "arduinoespressif" in tmpdir.join(".clang_complete").read()
|
||||
@ -104,15 +106,13 @@ def test_init_special_board(clirunner, validate_cliresult):
|
||||
boards = json.loads(result.output)
|
||||
|
||||
config = util.load_project_config()
|
||||
expected_result = [
|
||||
("platform", str(boards[0]['platform'])),
|
||||
("framework", str(boards[0]['frameworks'][0])), ("board", "uno")
|
||||
]
|
||||
expected_result = [("platform", str(boards[0]['platform'])),
|
||||
("framework",
|
||||
str(boards[0]['frameworks'][0])), ("board", "uno")]
|
||||
|
||||
assert config.has_section("env:uno")
|
||||
assert len(
|
||||
set(expected_result).symmetric_difference(
|
||||
set(config.items("env:uno")))) == 0
|
||||
assert not set(expected_result).symmetric_difference(
|
||||
set(config.items("env:uno")))
|
||||
|
||||
|
||||
def test_init_enable_auto_uploading(clirunner, validate_cliresult):
|
||||
@ -122,14 +122,11 @@ def test_init_enable_auto_uploading(clirunner, validate_cliresult):
|
||||
validate_cliresult(result)
|
||||
validate_pioproject(getcwd())
|
||||
config = util.load_project_config()
|
||||
expected_result = [
|
||||
("platform", "atmelavr"), ("framework", "arduino"),
|
||||
("board", "uno"), ("targets", "upload")
|
||||
]
|
||||
expected_result = [("platform", "atmelavr"), ("framework", "arduino"),
|
||||
("board", "uno"), ("targets", "upload")]
|
||||
assert config.has_section("env:uno")
|
||||
assert len(
|
||||
set(expected_result).symmetric_difference(
|
||||
set(config.items("env:uno")))) == 0
|
||||
assert not set(expected_result).symmetric_difference(
|
||||
set(config.items("env:uno")))
|
||||
|
||||
|
||||
def test_init_custom_framework(clirunner, validate_cliresult):
|
||||
@ -139,14 +136,11 @@ def test_init_custom_framework(clirunner, validate_cliresult):
|
||||
validate_cliresult(result)
|
||||
validate_pioproject(getcwd())
|
||||
config = util.load_project_config()
|
||||
expected_result = [
|
||||
("platform", "teensy"), ("framework", "mbed"),
|
||||
("board", "teensy31")
|
||||
]
|
||||
expected_result = [("platform", "teensy"), ("framework", "mbed"),
|
||||
("board", "teensy31")]
|
||||
assert config.has_section("env:teensy31")
|
||||
assert len(
|
||||
set(expected_result).symmetric_difference(
|
||||
set(config.items("env:teensy31")))) == 0
|
||||
assert not set(expected_result).symmetric_difference(
|
||||
set(config.items("env:teensy31")))
|
||||
|
||||
|
||||
def test_init_incorrect_board(clirunner):
|
||||
|
@ -148,8 +148,8 @@ def test_global_lib_list(clirunner, validate_cliresult):
|
||||
items2 = [
|
||||
"OneWire", "DHT22", "PJON", "ESPAsyncTCP", "ArduinoJson",
|
||||
"PubSubClient", "rs485-nodeproto", "Adafruit ST7735 Library",
|
||||
"RadioHead-1.62", "DallasTemperature", "NeoPixelBus",
|
||||
"RFcontrol", "platformio-libmirror"
|
||||
"RadioHead-1.62", "DallasTemperature", "NeoPixelBus", "RFcontrol",
|
||||
"platformio-libmirror"
|
||||
]
|
||||
assert set(items1) == set(items2)
|
||||
|
||||
|
@ -24,27 +24,25 @@ def test_search_json_output(clirunner, validate_cliresult, isolated_pio_home):
|
||||
validate_cliresult(result)
|
||||
search_result = json.loads(result.output)
|
||||
assert isinstance(search_result, list)
|
||||
assert len(search_result)
|
||||
assert search_result
|
||||
platforms = [item['name'] for item in search_result]
|
||||
assert "atmelsam" in platforms
|
||||
|
||||
|
||||
def test_search_raw_output(clirunner, validate_cliresult, isolated_pio_home):
|
||||
def test_search_raw_output(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cli_platform.platform_search, ["arduino"])
|
||||
validate_cliresult(result)
|
||||
assert "teensy" in result.output
|
||||
|
||||
|
||||
def test_install_unknown_version(clirunner, validate_cliresult,
|
||||
isolated_pio_home):
|
||||
def test_install_unknown_version(clirunner):
|
||||
result = clirunner.invoke(cli_platform.platform_install,
|
||||
["atmelavr@99.99.99"])
|
||||
assert result.exit_code == -1
|
||||
assert isinstance(result.exception, exception.UndefinedPackageVersion)
|
||||
|
||||
|
||||
def test_install_unknown_from_registry(clirunner, validate_cliresult,
|
||||
isolated_pio_home):
|
||||
def test_install_unknown_from_registry(clirunner):
|
||||
result = clirunner.invoke(cli_platform.platform_install,
|
||||
["unknown-platform"])
|
||||
assert result.exit_code == -1
|
||||
@ -63,7 +61,7 @@ def test_install_known_version(clirunner, validate_cliresult,
|
||||
assert len(isolated_pio_home.join("packages").listdir()) == 1
|
||||
|
||||
|
||||
def test_install_from_vcs(clirunner, validate_cliresult, isolated_pio_home):
|
||||
def test_install_from_vcs(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cli_platform.platform_install, [
|
||||
"https://github.com/platformio/"
|
||||
"platform-espressif8266.git#feature/stage", "--skip-default-package"
|
||||
@ -72,17 +70,17 @@ def test_install_from_vcs(clirunner, validate_cliresult, isolated_pio_home):
|
||||
assert "espressif8266" in result.output
|
||||
|
||||
|
||||
def test_list_json_output(clirunner, validate_cliresult, isolated_pio_home):
|
||||
def test_list_json_output(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cli_platform.platform_list, ["--json-output"])
|
||||
validate_cliresult(result)
|
||||
list_result = json.loads(result.output)
|
||||
assert isinstance(list_result, list)
|
||||
assert len(list_result)
|
||||
assert list_result
|
||||
platforms = [item['name'] for item in list_result]
|
||||
assert set(["atmelavr", "espressif8266"]) == set(platforms)
|
||||
|
||||
|
||||
def test_list_raw_output(clirunner, validate_cliresult, isolated_pio_home):
|
||||
def test_list_raw_output(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cli_platform.platform_list)
|
||||
validate_cliresult(result)
|
||||
assert all(
|
||||
@ -111,4 +109,4 @@ def test_uninstall(clirunner, validate_cliresult, isolated_pio_home):
|
||||
result = clirunner.invoke(cli_platform.platform_uninstall,
|
||||
["atmelavr", "espressif8266"])
|
||||
validate_cliresult(result)
|
||||
assert len(isolated_pio_home.join("platforms").listdir()) == 0
|
||||
assert not isolated_pio_home.join("platforms").listdir()
|
||||
|
@ -19,6 +19,6 @@ from platformio.commands.settings import cli
|
||||
def test_settings_check(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cli, ["get"])
|
||||
validate_cliresult(result)
|
||||
assert len(result.output)
|
||||
assert result.output
|
||||
for item in app.DEFAULT_SETTINGS.items():
|
||||
assert item[0] in result.output
|
||||
|
@ -16,11 +16,7 @@ from platformio.commands.update import cli as cmd_update
|
||||
|
||||
|
||||
def test_update(clirunner, validate_cliresult):
|
||||
matches = (
|
||||
"Platform Manager",
|
||||
"Up-to-date",
|
||||
"Library Manager"
|
||||
)
|
||||
matches = ("Platform Manager", "Up-to-date", "Library Manager")
|
||||
result = clirunner.invoke(cmd_update, ["--only-check"])
|
||||
validate_cliresult(result)
|
||||
assert all([m in result.output for m in matches])
|
||||
|
@ -57,8 +57,7 @@ def test_after_upgrade_2_to_3(clirunner, validate_cliresult,
|
||||
assert board_ids == set([b['id'] for b in json.loads(result.output)])
|
||||
|
||||
|
||||
def test_after_upgrade_silence(clirunner, validate_cliresult,
|
||||
isolated_pio_home):
|
||||
def test_after_upgrade_silence(clirunner, validate_cliresult):
|
||||
app.set_state_item("last_version", "2.11.2")
|
||||
result = clirunner.invoke(cli_pio, ["boards", "--json-output"])
|
||||
validate_cliresult(result)
|
||||
@ -66,7 +65,7 @@ def test_after_upgrade_silence(clirunner, validate_cliresult,
|
||||
assert any([b['id'] == "uno" for b in boards])
|
||||
|
||||
|
||||
def test_check_pio_upgrade(clirunner, validate_cliresult, isolated_pio_home):
|
||||
def test_check_pio_upgrade(clirunner, validate_cliresult):
|
||||
|
||||
def _patch_pio_version(version):
|
||||
maintenance.__version__ = version
|
||||
@ -96,7 +95,7 @@ def test_check_pio_upgrade(clirunner, validate_cliresult, isolated_pio_home):
|
||||
_patch_pio_version(origin_version)
|
||||
|
||||
|
||||
def test_check_lib_updates(clirunner, validate_cliresult, isolated_pio_home):
|
||||
def test_check_lib_updates(clirunner, validate_cliresult):
|
||||
# install obsolete library
|
||||
result = clirunner.invoke(cli_pio,
|
||||
["lib", "-g", "install", "ArduinoJson@<5.7"])
|
||||
@ -113,8 +112,7 @@ def test_check_lib_updates(clirunner, validate_cliresult, isolated_pio_home):
|
||||
result.output)
|
||||
|
||||
|
||||
def test_check_and_update_libraries(clirunner, validate_cliresult,
|
||||
isolated_pio_home):
|
||||
def test_check_and_update_libraries(clirunner, validate_cliresult):
|
||||
# enable library auto-updates
|
||||
result = clirunner.invoke(
|
||||
cli_pio, ["settings", "set", "auto_update_libraries", "Yes"])
|
||||
@ -168,8 +166,7 @@ def test_check_platform_updates(clirunner, validate_cliresult,
|
||||
assert "There are the new updates for platforms (native)" in result.output
|
||||
|
||||
|
||||
def test_check_and_update_platforms(clirunner, validate_cliresult,
|
||||
isolated_pio_home):
|
||||
def test_check_and_update_platforms(clirunner, validate_cliresult):
|
||||
# enable library auto-updates
|
||||
result = clirunner.invoke(
|
||||
cli_pio, ["settings", "set", "auto_update_platforms", "Yes"])
|
||||
@ -190,8 +187,7 @@ def test_check_and_update_platforms(clirunner, validate_cliresult,
|
||||
validate_cliresult(result)
|
||||
assert "There are the new updates for platforms (native)" in result.output
|
||||
assert "Please wait while updating platforms" in result.output
|
||||
assert re.search(r"Updating native\s+@ 0.0.0\s+\[[\d\.]+\]",
|
||||
result.output)
|
||||
assert re.search(r"Updating native\s+@ 0.0.0\s+\[[\d\.]+\]", result.output)
|
||||
|
||||
# check updated version
|
||||
result = clirunner.invoke(cli_pio, ["platform", "list", "--json-output"])
|
||||
|
@ -186,7 +186,7 @@ def test_install_packages(isolated_pio_home, tmpdir):
|
||||
"packages").listdir()]) == set(pkg_dirnames)
|
||||
|
||||
|
||||
def test_get_package(isolated_pio_home):
|
||||
def test_get_package():
|
||||
tests = [
|
||||
[("unknown", ), None],
|
||||
[("1", ), None],
|
||||
|
Reference in New Issue
Block a user