Skip to content

Commit

Permalink
Ensure support for Python 3.13 (#669)
Browse files Browse the repository at this point in the history
* Add tests with Python 3.13

* Remove tick=false and update time_machine

* Add Python 3.13 to setup.py

* pre-commit auto-update
  • Loading branch information
rikroe authored Nov 24, 2024
1 parent 81a1da6 commit ce07342
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
fail-fast: false
steps:
- uses: actions/checkout@v3
Expand Down
14 changes: 5 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.6.2
rev: v0.8.0
hooks:
- id: ruff
args:
- --fix
- repo: https://github.com/psf/black
rev: 24.8.0
rev: 24.10.0
hooks:
- id: black
args:
Expand All @@ -17,14 +17,10 @@ repos:
rev: v2.3.0
hooks:
- id: codespell
args:
# - --ignore-words-list=hass,alot,datas,dof,dur,ether,farenheit,hist,iff,iif,ines,ist,lightsensor,mut,nd,pres,referer,rime,ser,serie,te,technik,ue,uint,visability,wan,wanna,withing,iam,incomfort,ba,haa
- --skip="./.*,*.csv,*.json"
- --quiet-level=2
exclude_types: [csv, json]
exclude: ^test/responses/
additional_dependencies:
- tomli
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.1
rev: v1.13.0
hooks:
- id: mypy
name: mypy
Expand Down
25 changes: 16 additions & 9 deletions bimmer_connected/tests/test_remote_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,28 +347,35 @@ async def test_get_remote_position_fail_without_observer(caplog, bmw_fixture: re


@pytest.mark.asyncio
async def test_fail_with_timeout(bmw_fixture: respx.Router):
async def test_fail_with_timeout(monkeypatch: pytest.MonkeyPatch, bmw_fixture: respx.Router):
"""Test failing after timeout was reached."""
remote_services._POLLING_CYCLE = 1
remote_services._POLLING_TIMEOUT = 2

account = await prepare_account_with_vehicles()
vehicle = account.get_vehicle(VIN_G26)
with monkeypatch.context() as m:
m.setattr(remote_services, "_POLLING_CYCLE", 1)
m.setattr(remote_services, "_POLLING_TIMEOUT", 1)

with pytest.raises(MyBMWRemoteServiceError):
await vehicle.remote_services.trigger_remote_light_flash()
account = await prepare_account_with_vehicles()
vehicle = account.get_vehicle(VIN_G26)

with pytest.raises(MyBMWRemoteServiceError):
await vehicle.remote_services.trigger_remote_light_flash()

@time_machine.travel("2020-01-01", tick=False)

# @time_machine.travel("2020-01-01")
@pytest.mark.asyncio
async def test_get_remote_position_too_old(bmw_fixture: respx.Router):
"""Test remote service position being ignored as vehicle status is newer."""

account = await prepare_account_with_vehicles()
account.set_observer_position(1.0, 0.0)
vehicle = account.get_vehicle(VIN_G26)
location = vehicle.vehicle_location

await vehicle.remote_services.trigger_remote_vehicle_finder()
assert location.location == (48.177334, 11.556274)
assert location.heading == 180

with time_machine.travel("2020-01-02"):
await vehicle.remote_services.trigger_remote_vehicle_finder()

assert location.location == (48.177334, 11.556274)
assert location.heading == 180
Expand Down
6 changes: 3 additions & 3 deletions bimmer_connected/tests/test_vehicle_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ async def test_range_electric(caplog, bmw_fixture: respx.Router):
assert len(get_deprecation_warning_count(caplog)) == 0


@time_machine.travel("2021-11-28 21:28:59 +0000", tick=False)
@time_machine.travel("2021-11-28 21:28:59 +0000")
@pytest.mark.asyncio
async def test_charging_end_time(caplog, bmw_fixture: respx.Router):
"""Test charging end time."""
Expand All @@ -186,7 +186,7 @@ async def test_charging_end_time(caplog, bmw_fixture: respx.Router):
assert len(get_deprecation_warning_count(caplog)) == 0


@time_machine.travel("2021-11-28 17:28:59 +0000", tick=False)
@time_machine.travel("2021-11-28 17:28:59 +0000")
@pytest.mark.asyncio
async def test_plugged_in_waiting_for_charge_window(caplog, bmw_fixture: respx.Router):
"""I01_REX is plugged in but not charging, as its waiting for charging window."""
Expand Down Expand Up @@ -469,7 +469,7 @@ async def test_tires(bmw_fixture: respx.Router):
assert tires.rear_left.season == 2


@time_machine.travel("2021-11-28 21:28:59 +0000", tick=False)
@time_machine.travel("2021-11-28 21:28:59 +0000")
@pytest.mark.asyncio
async def test_climate(bmw_fixture: respx.Router):
"""Test climate status."""
Expand Down
2 changes: 1 addition & 1 deletion bimmer_connected/vehicle/vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async def get_vehicle_state(self) -> None:
"""Retrieve vehicle data from BMW servers."""
_LOGGER.debug("Getting vehicle list")

fetched_at = datetime.datetime.now(datetime.timezone.utc)
fetched_at = datetime.datetime.now(datetime.timezone.utc).replace(microsecond=0)

async with MyBMWClient(self.account.config) as client:
# Get state details
Expand Down
10 changes: 9 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,12 @@ ignore = [
"bimmer_connected/api/authentication.py" = ["D102", "D107"]

[tool.ruff.lint.mccabe]
max-complexity = 25
max-complexity = 25

[tool.codespell]
skip = "*.csv,*.json"
quiet-level = 2
ignore-words-list = [
"hass",
"socio-economic"
]
2 changes: 1 addition & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ black
mypy
types-setuptools
pbr
time_machine<2.13.0
time_machine
pre-commit
backports.zoneinfo;python_version<"3.9"
ruff
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ classifier =
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3.13
keywords =
BMW
Connected Drive
Expand Down

0 comments on commit ce07342

Please sign in to comment.