freeipa/pypi/test_placeholder.py
Christian Heimes a48f6511f6 Use namespace-aware meta importer for ipaplatform
Instead of symlinks and build-time configuration the ipaplatform module
is now able to auto-detect platforms on import time. The meta importer
uses the platform 'ID' from /etc/os-releases. It falls back to 'ID_LIKE'
on platforms like CentOS, which has ID=centos and ID_LIKE="rhel fedora".

The meta importer is able to handle namespace packages and the
ipaplatform package has been turned into a namespace package in order to
support external platform specifications.

https://fedorahosted.org/freeipa/ticket/6474

Signed-off-by: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
2017-11-15 14:17:24 +01:00

50 lines
1.0 KiB
Python

#!/usr/bin/env python
# Copyright (C) 2017 FreeIPA Contributors see COPYING for license
import importlib
import pkg_resources
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):
pkg_resources.require(pkgname)