Use importlib metadata to check installed packages (#24114)
* Use importlib metadata * Fix script * Remove unused import * Update requirements"
This commit is contained in:
parent
96b7bb625d
commit
179fb0f3b5
8 changed files with 52 additions and 111 deletions
|
@ -6,13 +6,20 @@ import sys
|
|||
from subprocess import PIPE
|
||||
from unittest.mock import MagicMock, call, patch
|
||||
|
||||
import pkg_resources
|
||||
import pytest
|
||||
|
||||
import homeassistant.util.package as package
|
||||
|
||||
|
||||
RESOURCE_DIR = os.path.abspath(
|
||||
os.path.join(os.path.dirname(__file__), '..', 'resources'))
|
||||
|
||||
TEST_NEW_REQ = 'pyhelloworld3==1.0.0'
|
||||
|
||||
TEST_ZIP_REQ = 'file://{}#{}' \
|
||||
.format(os.path.join(RESOURCE_DIR, 'pyhelloworld3.zip'), TEST_NEW_REQ)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_sys():
|
||||
|
@ -176,3 +183,14 @@ def test_async_get_user_site(mock_env_copy):
|
|||
stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.DEVNULL,
|
||||
env=env)
|
||||
assert ret == os.path.join(deps_dir, 'lib_dir')
|
||||
|
||||
|
||||
def test_check_package_global():
|
||||
"""Test for an installed package."""
|
||||
installed_package = list(pkg_resources.working_set)[0].project_name
|
||||
assert package.is_installed(installed_package)
|
||||
|
||||
|
||||
def test_check_package_zip():
|
||||
"""Test for an installed zip package."""
|
||||
assert not package.is_installed(TEST_ZIP_REQ)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue