Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change dev environment to Python 3.13 #353

Merged
merged 3 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Depending on setup, "remoteUser": "vscode", might be preferred to add.
{
"name": "EV Smart Charging",
"image": "mcr.microsoft.com/devcontainers/python:3.12",
"image": "mcr.microsoft.com/devcontainers/python:3.13",
"postCreateCommand": "scripts/setup",
"forwardPorts": [
8123
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ jobs:
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version: ["3.11", "3.12"]
python-version: ["3.11", "3.12", "3.13"]
include:
- python-version: "3.11"
pytest_all_ha_versions: "pytest_all_ha_versions_python311"
- python-version: "3.12"
pytest_all_ha_versions: "pytest_all_ha_versions_python312"
- python-version: "3.13"
pytest_all_ha_versions: "pytest_all_ha_versions_python313"
steps:
- name: Check out code from GitHub
uses: "actions/checkout@v4"
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ jobs:
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version: ["3.11", "3.12"]
python-version: ["3.11", "3.12", "3.13"]
include:
- python-version: "3.11"
requirements: "requirements_test311.txt"
- python-version: "3.12"
requirements: "requirements_test312.txt"
- python-version: "3.13"
requirements: "requirements_test313.txt"
name: Run tests
steps:
- name: Check out code from GitHub
Expand All @@ -65,7 +67,7 @@ jobs:
-p no:sugar \
tests
- name: "Upload coverage to Codecov"
if: ${{ matrix.python-version == '3.12' }}
if: ${{ matrix.python-version == '3.13' }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ jobs:
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version: ["3.11", "3.12"]
python-version: ["3.11", "3.12", "3.13"]
include:
- python-version: "3.11"
requirements: "requirements_test311.txt"
- python-version: "3.12"
requirements: "requirements_test312.txt"
- python-version: "3.13"
requirements: "requirements_test313.txt"
name: Run tests
steps:
- name: Check out code from GitHub
Expand All @@ -69,7 +71,7 @@ jobs:
-p no:sugar \
tests
- name: "Upload coverage to Codecov"
if: ${{ matrix.python-version == '3.12' }}
if: ${{ matrix.python-version == '3.13' }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"debug-test"
],
"console": "integratedTerminal",
"justMyCode": false,
"env": {
"PYTEST_ADDOPTS": "--no-cov"
}
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.analysis.extraPaths": [
"/home/vscode/.local/lib/python3.10/site-packages/homeassistant"
"/home/vscode/.local/lib/python3.13/site-packages/homeassistant"
]
}
2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
colorlog==6.9.0
homeassistant==2024.7.4
homeassistant==2024.12.5
2 changes: 1 addition & 1 deletion requirements_test.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pytest-homeassistant-custom-component==0.13.148
pytest-homeassistant-custom-component==0.13.195
2 changes: 1 addition & 1 deletion requirements_test312.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pytest-homeassistant-custom-component==0.13.136
pytest-homeassistant-custom-component==0.13.195
1 change: 1 addition & 0 deletions requirements_test313.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest-homeassistant-custom-component==0.13.195
18 changes: 18 additions & 0 deletions scripts/pytest_all_ha_versions_python312
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,21 @@ run_next_test "auto"

pip3 install -qq homeassistant==2024.7.4 pytest-homeassistant-custom-component==0.13.148
run_next_test "auto"

pip3 install -qq homeassistant==2024.8.3 pytest-homeassistant-custom-component==0.13.155
run_next_test "auto"

pip3 install -qq homeassistant==2024.9.3 pytest-homeassistant-custom-component==0.13.164
run_next_test "auto"

pip3 install -qq homeassistant==2024.10.4 pytest-homeassistant-custom-component==0.13.175
run_next_test "auto"

pip3 install -qq homeassistant==2024.11.3 pytest-homeassistant-custom-component==0.13.184
run_next_test "auto"

pip3 install -qq homeassistant==2024.12.5 pytest-homeassistant-custom-component==0.13.195
run_next_test "auto"


# As of HA 2025.2, Python 3.12 is not supported.
39 changes: 39 additions & 0 deletions scripts/pytest_all_ha_versions_python313
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash

# https://github.com/home-assistant/core
# https://github.com/MatthewFlamm/pytest-homeassistant-custom-component

run_first_test() {
local asynciomode="$1" # First parameter, "strict" or "auto"
echo
pip3 list 2>/dev/null | grep homeassistant | grep -v "\-home"
pip3 list 2>/dev/null | grep pytest-homeassistant-custom-component
output=$(pytest -q --no-summary --asyncio-mode=$asynciomode tests 2>&1 | grep passed)
echo "$output"
number1=$(echo "$output" | awk '{print $1}')
if [ -z "$number1" ]; then
echo "No passed test cases!"
exit 1
fi
}

run_next_test() {
local asynciomode="$1" # First parameter, "strict" or "auto"
echo
pip3 list 2>/dev/null | grep homeassistant | grep -v "\-home"
pip3 list 2>/dev/null | grep pytest-homeassistant-custom-component
output=$(pytest -q --no-summary --asyncio-mode=$asynciomode tests 2>&1 | grep passed)
echo "$output"
number2=$(echo "$output" | awk '{print $1}')
if [ "$number1" != "$number2" ]; then
echo "Results are different!"
exit 1
fi
}

# As of HA 2024.12, Python 3.13 is supported.
pip3 install -qq homeassistant==2024.12.5 pytest-homeassistant-custom-component==0.13.195
run_first_test "auto"

#pip3 install -qq homeassistant==2025.1.x pytest-homeassistant-custom-component==0.13.xxx
#run_next_test "auto"
4 changes: 2 additions & 2 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ async def test_setup_new_integration_name(hass, bypass_validate_input_sensors):
)

# Change title
config_entry.title = "New title"
hass.config_entries.async_update_entry(config_entry, title="New title")

# Reload the entry and assert that the data from above is still there
assert await async_reload_entry(hass, config_entry) is None
Expand All @@ -239,7 +239,7 @@ async def test_setup_new_integration_name(hass, bypass_validate_input_sensors):
assert device.name_by_user == "New title" or device.name == "New title"

# Change a changed title
config_entry.title = "New title2"
hass.config_entries.async_update_entry(config_entry, title="New title2")

# Reload the entry and assert that the data from above is still there
assert await async_reload_entry(hass, config_entry) is None
Expand Down
Loading