From f7aad4a9e65a17c755437f408ea70940864266fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Fri, 6 Oct 2023 14:22:56 +0300 Subject: [PATCH] Call pytest as python3 -m pytest (#101185) --- .vscode/tasks.json | 6 +++--- script/lint_and_test.py | 9 ++++++++- script/scaffold/__main__.py | 11 +++++++++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index c767647f821..b8cb8a4e61a 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -16,7 +16,7 @@ { "label": "Pytest", "type": "shell", - "command": "pytest --timeout=10 tests", + "command": "python3 -m pytest --timeout=10 tests", "dependsOn": ["Install all Test Requirements"], "group": { "kind": "test", @@ -31,7 +31,7 @@ { "label": "Pytest (changed tests only)", "type": "shell", - "command": "pytest --timeout=10 --picked", + "command": "python3 -m pytest --timeout=10 --picked", "group": { "kind": "test", "isDefault": true @@ -75,7 +75,7 @@ "label": "Code Coverage", "detail": "Generate code coverage report for a given integration.", "type": "shell", - "command": "pytest ./tests/components/${input:integrationName}/ --cov=homeassistant.components.${input:integrationName} --cov-report term-missing --durations-min=1 --durations=0 --numprocesses=auto", + "command": "python3 -m pytest ./tests/components/${input:integrationName}/ --cov=homeassistant.components.${input:integrationName} --cov-report term-missing --durations-min=1 --durations=0 --numprocesses=auto", "group": { "kind": "test", "isDefault": true diff --git a/script/lint_and_test.py b/script/lint_and_test.py index ee37841b056..ee28d4765d6 100755 --- a/script/lint_and_test.py +++ b/script/lint_and_test.py @@ -223,7 +223,14 @@ async def main(): return code, _ = await async_exec( - "pytest", "-vv", "--force-sugar", "--", *test_files, display=True + "python3", + "-m", + "pytest", + "-vv", + "--force-sugar", + "--", + *test_files, + display=True, ) print("=============================") diff --git a/script/scaffold/__main__.py b/script/scaffold/__main__.py index 42a8355db59..8dafd8fa802 100644 --- a/script/scaffold/__main__.py +++ b/script/scaffold/__main__.py @@ -103,9 +103,16 @@ def main(): if args.develop: print("Running tests") - print(f"$ pytest -vvv tests/components/{info.domain}") + print(f"$ python3 -m pytest -vvv tests/components/{info.domain}") subprocess.run( - ["pytest", "-vvv", f"tests/components/{info.domain}"], check=True + [ + "python3", + "-m", + "pytest", + "-vvv", + f"tests/components/{info.domain}", + ], + check=True, ) print()