Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
HomeAssistant
Core
Commits
18722aec
Unverified
Commit
18722aec
authored
9 months ago
by
epenet
Committed by
GitHub
9 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Improve type hints and fix pylint warnings in util tests (#119355)
parent
e14146d7
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
tests/util/test_json.py
+1
-1
1 addition, 1 deletion
tests/util/test_json.py
tests/util/test_location.py
+8
-5
8 additions, 5 deletions
tests/util/test_location.py
tests/util/test_unit_system.py
+2
-3
2 additions, 3 deletions
tests/util/test_unit_system.py
with
11 additions
and
9 deletions
tests/util/test_json.py
+
1
−
1
View file @
18722aec
...
...
@@ -159,7 +159,7 @@ async def test_deprecated_save_json(
assert
"
should be updated to use homeassistant.helpers.json module
"
in
caplog
.
text
async
def
test_loading_derived_class
():
async
def
test_loading_derived_class
()
->
None
:
"""
Test loading data from classes derived from str.
"""
class
MyStr
(
str
):
...
...
This diff is collapsed.
Click to expand it.
tests/util/test_location.py
+
8
−
5
View file @
18722aec
...
...
@@ -5,6 +5,7 @@ from unittest.mock import Mock, patch
import
aiohttp
import
pytest
from
homeassistant.core
import
HomeAssistant
from
homeassistant.helpers.aiohttp_client
import
async_get_clientsession
import
homeassistant.util.location
as
location_util
...
...
@@ -28,13 +29,13 @@ DISTANCE_MILES = 3632.78
@pytest.fixture
async
def
session
(
hass
)
:
async
def
session
(
hass
:
HomeAssistant
)
->
aiohttp
.
ClientSession
:
"""
Return aioclient session.
"""
return
async_get_clientsession
(
hass
)
@pytest.fixture
async
def
raising_session
():
async
def
raising_session
()
->
Mock
:
"""
Return an aioclient session that only fails.
"""
return
Mock
(
get
=
Mock
(
side_effect
=
aiohttp
.
ClientError
))
...
...
@@ -76,7 +77,7 @@ def test_get_miles() -> None:
async
def
test_detect_location_info_whoami
(
aioclient_mock
:
AiohttpClientMocker
,
session
aioclient_mock
:
AiohttpClientMocker
,
session
:
aiohttp
.
ClientSession
)
->
None
:
"""
Test detect location info using services.home-assistant.io/whoami.
"""
aioclient_mock
.
get
(
location_util
.
WHOAMI_URL
,
text
=
load_fixture
(
"
whoami.json
"
))
...
...
@@ -99,7 +100,9 @@ async def test_detect_location_info_whoami(
assert
info
.
use_metric
async
def
test_dev_url
(
aioclient_mock
:
AiohttpClientMocker
,
session
)
->
None
:
async
def
test_dev_url
(
aioclient_mock
:
AiohttpClientMocker
,
session
:
aiohttp
.
ClientSession
)
->
None
:
"""
Test usage of dev URL.
"""
aioclient_mock
.
get
(
location_util
.
WHOAMI_URL_DEV
,
text
=
load_fixture
(
"
whoami.json
"
))
with
patch
(
"
homeassistant.util.location.HA_VERSION
"
,
"
1.0.dev0
"
):
...
...
@@ -110,7 +113,7 @@ async def test_dev_url(aioclient_mock: AiohttpClientMocker, session) -> None:
assert
info
.
currency
==
"
XXX
"
async
def
test_whoami_query_raises
(
raising_session
)
->
None
:
async
def
test_whoami_query_raises
(
raising_session
:
Mock
)
->
None
:
"""
Test whoami query when the request to API fails.
"""
info
=
await
location_util
.
_get_whoami
(
raising_session
)
assert
info
is
None
This diff is collapsed.
Click to expand it.
tests/util/test_unit_system.py
+
2
−
3
View file @
18722aec
...
...
@@ -4,8 +4,7 @@ from __future__ import annotations
import
pytest
from
homeassistant.components.sensor
import
SensorDeviceClass
from
homeassistant.components.sensor.const
import
DEVICE_CLASS_UNITS
from
homeassistant.components.sensor
import
DEVICE_CLASS_UNITS
,
SensorDeviceClass
from
homeassistant.const
import
(
ACCUMULATED_PRECIPITATION
,
LENGTH
,
...
...
@@ -23,7 +22,7 @@ from homeassistant.const import (
UnitOfVolumetricFlux
,
)
from
homeassistant.exceptions
import
HomeAssistantError
from
homeassistant.util.unit_system
import
(
from
homeassistant.util.unit_system
import
(
# pylint: disable=hass-deprecated-import
_CONF_UNIT_SYSTEM_IMPERIAL
,
_CONF_UNIT_SYSTEM_METRIC
,
_CONF_UNIT_SYSTEM_US_CUSTOMARY
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment