Skip to content

Commit

Permalink
models: Do not make references for private symbols
Browse files Browse the repository at this point in the history
Previously there was a reference for Models created for every symbol
attempted to being imported from leapp.models, however pytest tries to
import `_pytestfixturefunction` which is not a model obviously.
To work around pytest causing failures because of that, private symbols
are being filtered from the model reference creation magic.

Signed-off-by: Vinzenz Feenstra <vfeenstr@redhat.com>
  • Loading branch information
vinzenz committed Jun 17, 2021
1 parent bcd6580 commit 42a443b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions leapp/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ class Foobar(Model):
"""
import sys

from leapp.exceptions import ModelDefinitionError
from leapp.models import fields
from leapp.models.error_severity import ErrorSeverity

from leapp.exceptions import ModelDefinitionError
from leapp.models.fields import ModelMisuseError
from leapp.topics import DialogTopic, ErrorTopic, Topic
from leapp.utils.meta import get_flattened_subclasses, with_metaclass
from leapp.topics import ErrorTopic, DialogTopic, Topic


class ModelMeta(type):
Expand Down Expand Up @@ -219,6 +218,10 @@ def __delattr__(self, name):
delattr(self._module, name)

def __getattr__(self, item):
# Redirect private imports to the module and don't use our magic
# We do not support importing private Module symbols
if item.startswith('_'):
return getattr(self._module, item)
return getattr(self._module, item, None) or _module_ref(item)

sys.modules[__name__] = ReferenceDict(sys.modules[__name__])
Expand Down

0 comments on commit 42a443b

Please sign in to comment.