mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-27 11:06:32 +00:00
Migrate to python 3.8 (#1824)
* Migrate to python 3.8 * Fix tests on Py38 * cleanup tests Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
parent
7f4284f2af
commit
bdfcf1a2df
@ -1,4 +1,4 @@
|
|||||||
FROM mcr.microsoft.com/vscode/devcontainers/python:0-3.7
|
FROM mcr.microsoft.com/vscode/devcontainers/python:0-3.8
|
||||||
|
|
||||||
WORKDIR /workspaces
|
WORKDIR /workspaces
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
"python.linting.pylintEnabled": true,
|
"python.linting.pylintEnabled": true,
|
||||||
"python.linting.enabled": true,
|
"python.linting.enabled": true,
|
||||||
"python.formatting.provider": "black",
|
"python.formatting.provider": "black",
|
||||||
"python.formatting.blackArgs": ["--target-version", "py37"],
|
"python.formatting.blackArgs": ["--target-version", "py38"],
|
||||||
"editor.formatOnPaste": false,
|
"editor.formatOnPaste": false,
|
||||||
"editor.formatOnSave": true,
|
"editor.formatOnSave": true,
|
||||||
"editor.formatOnType": true,
|
"editor.formatOnType": true,
|
||||||
|
4
.github/workflows/ci.yaml
vendored
4
.github/workflows/ci.yaml
vendored
@ -89,7 +89,7 @@ jobs:
|
|||||||
- name: Run black
|
- name: Run black
|
||||||
run: |
|
run: |
|
||||||
. venv/bin/activate
|
. venv/bin/activate
|
||||||
black --target-version py37 --check supervisor tests setup.py
|
black --target-version py38 --check supervisor tests setup.py
|
||||||
|
|
||||||
lint-dockerfile:
|
lint-dockerfile:
|
||||||
name: Check Dockerfile
|
name: Check Dockerfile
|
||||||
@ -345,7 +345,7 @@ jobs:
|
|||||||
needs: prepare
|
needs: prepare
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
python-version: [3.7, 3.8]
|
python-version: [3.8]
|
||||||
name: Run tests Python ${{ matrix.python-version }}
|
name: Run tests Python ${{ matrix.python-version }}
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code from GitHub
|
- name: Check out code from GitHub
|
||||||
|
15
.github/workflows/release-drafter.yml
vendored
Normal file
15
.github/workflows/release-drafter.yml
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
name: Release Drafter
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
# branches to consider in the event; optional, defaults to all
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update_release_draft:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: release-drafter/release-drafter@v5
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
@ -22,9 +22,9 @@ jobs:
|
|||||||
sudo apt-get install -y libpulse0 libudev1
|
sudo apt-get install -y libpulse0 libudev1
|
||||||
displayName: "Install Host library"
|
displayName: "Install Host library"
|
||||||
- task: UsePythonVersion@0
|
- task: UsePythonVersion@0
|
||||||
displayName: "Use Python 3.7"
|
displayName: "Use Python 3.8"
|
||||||
inputs:
|
inputs:
|
||||||
versionSpec: "3.7"
|
versionSpec: "3.8"
|
||||||
- script: pip install tox
|
- script: pip install tox
|
||||||
displayName: "Install Tox"
|
displayName: "Install Tox"
|
||||||
- script: tox
|
- script: tox
|
||||||
|
@ -20,9 +20,9 @@ jobs:
|
|||||||
vmImage: "ubuntu-latest"
|
vmImage: "ubuntu-latest"
|
||||||
steps:
|
steps:
|
||||||
- task: UsePythonVersion@0
|
- task: UsePythonVersion@0
|
||||||
displayName: "Use Python 3.7"
|
displayName: "Use Python 3.8"
|
||||||
inputs:
|
inputs:
|
||||||
versionSpec: "3.7"
|
versionSpec: "3.8"
|
||||||
- script: |
|
- script: |
|
||||||
setup_version="$(python setup.py -V)"
|
setup_version="$(python setup.py -V)"
|
||||||
branch_version="$(Build.SourceBranchName)"
|
branch_version="$(Build.SourceBranchName)"
|
||||||
|
@ -8,7 +8,7 @@ trigger:
|
|||||||
pr: none
|
pr: none
|
||||||
variables:
|
variables:
|
||||||
- name: versionWheels
|
- name: versionWheels
|
||||||
value: '1.6.1-3.7-alpine3.11'
|
value: '1.13.0-3.8-alpine3.12'
|
||||||
resources:
|
resources:
|
||||||
repositories:
|
repositories:
|
||||||
- repository: azure
|
- repository: azure
|
||||||
|
10
build.json
10
build.json
@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"image": "homeassistant/{arch}-hassio-supervisor",
|
"image": "homeassistant/{arch}-hassio-supervisor",
|
||||||
"build_from": {
|
"build_from": {
|
||||||
"aarch64": "homeassistant/aarch64-base-python:3.7-alpine3.11",
|
"aarch64": "homeassistant/aarch64-base-python:3.8-alpine3.12",
|
||||||
"armhf": "homeassistant/armhf-base-python:3.7-alpine3.11",
|
"armhf": "homeassistant/armhf-base-python:3.8-alpine3.12",
|
||||||
"armv7": "homeassistant/armv7-base-python:3.7-alpine3.11",
|
"armv7": "homeassistant/armv7-base-python:3.8-alpine3.12",
|
||||||
"amd64": "homeassistant/amd64-base-python:3.7-alpine3.11",
|
"amd64": "homeassistant/amd64-base-python:3.8-alpine3.12",
|
||||||
"i386": "homeassistant/i386-base-python:3.7-alpine3.11"
|
"i386": "homeassistant/i386-base-python:3.8-alpine3.12"
|
||||||
},
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"io.hass.type": "supervisor"
|
"io.hass.type": "supervisor"
|
||||||
|
2
setup.py
2
setup.py
@ -25,7 +25,7 @@ setup(
|
|||||||
"Topic :: Scientific/Engineering :: Atmospheric Science",
|
"Topic :: Scientific/Engineering :: Atmospheric Science",
|
||||||
"Development Status :: 5 - Production/Stable",
|
"Development Status :: 5 - Production/Stable",
|
||||||
"Intended Audience :: Developers",
|
"Intended Audience :: Developers",
|
||||||
"Programming Language :: Python :: 3.7",
|
"Programming Language :: Python :: 3.8",
|
||||||
],
|
],
|
||||||
keywords=["docker", "home-assistant", "api"],
|
keywords=["docker", "home-assistant", "api"],
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
|
@ -7,20 +7,3 @@ def load_json_fixture(filename):
|
|||||||
"""Load a fixture."""
|
"""Load a fixture."""
|
||||||
path = Path(Path(__file__).parent.joinpath("fixtures"), filename)
|
path = Path(Path(__file__).parent.joinpath("fixtures"), filename)
|
||||||
return json.loads(path.read_text())
|
return json.loads(path.read_text())
|
||||||
|
|
||||||
|
|
||||||
def mock_coro(return_value=None, exception=None):
|
|
||||||
"""Return a coro that returns a value or raise an exception."""
|
|
||||||
return mock_coro_func(return_value, exception)()
|
|
||||||
|
|
||||||
|
|
||||||
def mock_coro_func(return_value=None, exception=None):
|
|
||||||
"""Return a method to create a coro function that returns a value."""
|
|
||||||
|
|
||||||
async def coro(*args, **kwargs):
|
|
||||||
"""Fake coroutine."""
|
|
||||||
if exception:
|
|
||||||
raise exception
|
|
||||||
return return_value
|
|
||||||
|
|
||||||
return coro
|
|
||||||
|
@ -5,8 +5,6 @@ import pytest
|
|||||||
|
|
||||||
from supervisor.bootstrap import initialize_coresys
|
from supervisor.bootstrap import initialize_coresys
|
||||||
|
|
||||||
from tests.common import mock_coro
|
|
||||||
|
|
||||||
# pylint: disable=redefined-outer-name
|
# pylint: disable=redefined-outer-name
|
||||||
|
|
||||||
|
|
||||||
@ -21,8 +19,7 @@ def docker():
|
|||||||
async def coresys(loop, docker):
|
async def coresys(loop, docker):
|
||||||
"""Create a CoreSys Mock."""
|
"""Create a CoreSys Mock."""
|
||||||
with patch("supervisor.bootstrap.initialize_system_data"), patch(
|
with patch("supervisor.bootstrap.initialize_system_data"), patch(
|
||||||
"supervisor.bootstrap.fetch_timezone",
|
"supervisor.bootstrap.fetch_timezone", return_value="Europe/Zurich",
|
||||||
return_value=mock_coro(return_value="Europe/Zurich"),
|
|
||||||
):
|
):
|
||||||
coresys_obj = await initialize_coresys()
|
coresys_obj = await initialize_coresys()
|
||||||
|
|
||||||
|
@ -24,23 +24,23 @@ async def test_dns_url_v4_good():
|
|||||||
assert supervisor.validate.dns_url(url)
|
assert supervisor.validate.dns_url(url)
|
||||||
|
|
||||||
|
|
||||||
async def test_dns_url_v6_good():
|
def test_dns_url_v6_good():
|
||||||
"""Test the DNS validator with known-good ipv6 DNS URLs."""
|
"""Test the DNS validator with known-good ipv6 DNS URLs."""
|
||||||
for url in GOOD_V6:
|
for url in GOOD_V6:
|
||||||
assert supervisor.validate.dns_url(url)
|
assert supervisor.validate.dns_url(url)
|
||||||
|
|
||||||
|
|
||||||
async def test_dns_server_list_v4():
|
def test_dns_server_list_v4():
|
||||||
"""Test a list with v4 addresses."""
|
"""Test a list with v4 addresses."""
|
||||||
assert supervisor.validate.dns_server_list(GOOD_V4)
|
assert supervisor.validate.dns_server_list(GOOD_V4)
|
||||||
|
|
||||||
|
|
||||||
async def test_dns_server_list_v6():
|
def test_dns_server_list_v6():
|
||||||
"""Test a list with v6 addresses."""
|
"""Test a list with v6 addresses."""
|
||||||
assert supervisor.validate.dns_server_list(GOOD_V6)
|
assert supervisor.validate.dns_server_list(GOOD_V6)
|
||||||
|
|
||||||
|
|
||||||
async def test_dns_server_list_combined():
|
def test_dns_server_list_combined():
|
||||||
"""Test a list with both v4 and v6 addresses."""
|
"""Test a list with both v4 and v6 addresses."""
|
||||||
combined = GOOD_V4 + GOOD_V6
|
combined = GOOD_V4 + GOOD_V6
|
||||||
# test the matches
|
# test the matches
|
||||||
@ -52,14 +52,14 @@ async def test_dns_server_list_combined():
|
|||||||
supervisor.validate.dns_server_list(combined + combined + combined + combined)
|
supervisor.validate.dns_server_list(combined + combined + combined + combined)
|
||||||
|
|
||||||
|
|
||||||
async def test_dns_server_list_bad():
|
def test_dns_server_list_bad():
|
||||||
"""Test the bad list."""
|
"""Test the bad list."""
|
||||||
# test the matches
|
# test the matches
|
||||||
with pytest.raises(voluptuous.error.Invalid):
|
with pytest.raises(voluptuous.error.Invalid):
|
||||||
assert supervisor.validate.dns_server_list(BAD)
|
assert supervisor.validate.dns_server_list(BAD)
|
||||||
|
|
||||||
|
|
||||||
async def test_dns_server_list_bad_combined():
|
def test_dns_server_list_bad_combined():
|
||||||
"""Test the bad list, combined with the good."""
|
"""Test the bad list, combined with the good."""
|
||||||
combined = GOOD_V4 + GOOD_V6 + BAD
|
combined = GOOD_V4 + GOOD_V6 + BAD
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user