Move import of modulemd to a separate module

This should make it possible to only import the library only when it's
really needed.

DNF does not work with libmodulemd v2. If we import libmodulemd2 and
then dnf, the program will just hang forever. We only need DNF in
pungi-gather, where libmodulemd is not needed, and also where we do need
libmodulemd, we don't have DNF.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2019-10-02 09:40:18 +02:00
parent f822ee324a
commit 8ab7d9f7ba
15 changed files with 91 additions and 82 deletions

View file

@ -18,7 +18,8 @@ except ImportError:
import unittest
from pungi.util import get_arch_variant_data
from pungi import paths, checks, Modulemd
from pungi import paths, checks
from pungi.module_util import Modulemd
class BaseTestCase(unittest.TestCase):

View file

@ -19,7 +19,7 @@ from pungi.phases.createrepo import (CreaterepoPhase,
get_productids_from_scm,
ModulesMetadata)
from tests.helpers import DummyCompose, PungiTestCase, copy_fixture, touch
from pungi import Modulemd
from pungi.module_util import Modulemd
class TestCreaterepoPhase(PungiTestCase):

View file

@ -13,7 +13,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from pungi.phases.gather.sources.source_module import GatherSourceModule
from tests import helpers
from pungi import Modulemd
from pungi.module_util import Modulemd
@unittest.skipUnless(Modulemd is not None, "Skipped test, no module support.")

View file

@ -13,7 +13,7 @@ import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from pungi import Modulemd
from pungi.module_util import Modulemd
from pungi.phases import init
from tests.helpers import DummyCompose, PungiTestCase, touch, mk_boom, fake_run_in_threads

View file

@ -8,7 +8,7 @@ import mock
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from pungi import Modulemd
from pungi.module_util import Modulemd
from pungi.phases.pkgset import common
from tests import helpers

View file

@ -14,7 +14,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from pungi.phases.pkgset.sources import source_koji
from tests import helpers
from pungi import Modulemd
from pungi.module_util import Modulemd
EVENT_INFO = {'id': 15681980, 'ts': 1460956382.81936}
TAG_INFO = {
@ -613,7 +613,7 @@ class MockModule(object):
return self.path == other.path
@mock.patch("pungi.Modulemd.ModuleStream.read_file", new=MockModule)
@mock.patch("pungi.module_util.Modulemd.ModuleStream.read_file", new=MockModule)
@unittest.skipIf(Modulemd is None, "Skipping tests, no module support")
class TestAddModuleToVariant(helpers.PungiTestCase):