mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-11-02 20:30:26 -06:00
Use packaging.version and importlib.metadata instead. Note that packaging.version only parses versions compatible with Python packaging (originally defined in PEP 440). https://packaging.python.org/en/latest/specifications/version-specifiers/ Fixes https://pagure.io/freeipa/issue/9676 Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
48 lines
1.0 KiB
Python
48 lines
1.0 KiB
Python
# Copyright (C) 2017 FreeIPA Contributors see COPYING for license
|
|
|
|
import importlib
|
|
import importlib.metadata
|
|
|
|
import pytest
|
|
|
|
@pytest.mark.parametrize("modname", [
|
|
# placeholder packages raise ImportError
|
|
'ipaserver',
|
|
'ipatests',
|
|
# PyPI packages do not have install subpackage
|
|
'ipaclient.install',
|
|
'ipalib.install',
|
|
'ipapython.install',
|
|
# override module should not be shipped in wheels
|
|
'ipaplatform.override',
|
|
])
|
|
def test_fail_import(modname):
|
|
try:
|
|
importlib.import_module(modname)
|
|
except ImportError:
|
|
pass
|
|
else:
|
|
pytest.fail("'import {}' does not fail".format(modname))
|
|
|
|
|
|
@pytest.mark.parametrize("modname", [
|
|
'ipaclient',
|
|
'ipalib',
|
|
'ipaplatform',
|
|
'ipapython',
|
|
])
|
|
def test_import(modname):
|
|
importlib.import_module(modname)
|
|
|
|
|
|
@pytest.mark.parametrize("pkgname", [
|
|
'ipaclient',
|
|
'ipalib',
|
|
'ipaplatform',
|
|
'ipapython',
|
|
'ipaserver',
|
|
'ipatests',
|
|
])
|
|
def test_package_installed(pkgname):
|
|
importlib.metadata.distribution(pkgname)
|