Skip to content

Commit

Permalink
fixed test imports to be absolute
Browse files Browse the repository at this point in the history
  • Loading branch information
omry committed Feb 3, 2021
1 parent 5a798e0 commit 6b3e0d4
Show file tree
Hide file tree
Showing 17 changed files with 31 additions and 30 deletions.
1 change: 1 addition & 0 deletions omegaconf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ def _invalidate_flags_cache(self) -> None:
from .listconfig import ListConfig

# invalidate subtree cache only if the cache is initialized in this node.

if self.__dict__["_flags_cache"] is not None:
self.__dict__["_flags_cache"] = None
if isinstance(self, DictConfig):
Expand Down
1 change: 1 addition & 0 deletions omegaconf/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def validate_and_convert(self, value: Any) -> Any:
# allow_objects is internal and not an official API. use at your own risk.
# Please be aware that this support is subject to change without notice.
# If this is deemed useful and supportable it may become an official API.

if self._get_flag("allow_objects") is not True and not is_primitive_type(value):
t = get_type_of(value)
raise UnsupportedValueType(
Expand Down
4 changes: 2 additions & 2 deletions tests/examples/test_postponed_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires Python 3.7")
def test_simple_types_class_postponed() -> None:
# import from a module which has `from __future__ import annotations`
from .dataclass_postponed_annotations import simple_types_class
from tests.examples.dataclass_postponed_annotations import simple_types_class

simple_types_class()


@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires Python 3.7")
def test_conversions_postponed() -> None:
# import from a module which has `from __future__ import annotations`
from .dataclass_postponed_annotations import conversions
from tests.examples.dataclass_postponed_annotations import conversions

conversions()
3 changes: 1 addition & 2 deletions tests/test_base_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
read_write,
)
from omegaconf.errors import ConfigAttributeError, ConfigKeyError

from . import Color, StructuredWithMissing, User, does_not_raise
from tests import Color, StructuredWithMissing, User, does_not_raise


@pytest.mark.parametrize(
Expand Down
10 changes: 8 additions & 2 deletions tests/test_basic_ops_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@
)
from omegaconf.basecontainer import BaseContainer
from omegaconf.errors import ConfigKeyError, ConfigTypeError, KeyValidationError

from . import ConcretePlugin, Enum1, IllegalType, Plugin, StructuredWithMissing, User
from tests import (
ConcretePlugin,
Enum1,
IllegalType,
Plugin,
StructuredWithMissing,
User,
)


def test_setattr_deep_value() -> None:
Expand Down
3 changes: 1 addition & 2 deletions tests/test_basic_ops_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
ValidationError,
)
from omegaconf.nodes import IntegerNode, StringNode

from . import Color, IllegalType, User, does_not_raise
from tests import Color, IllegalType, User, does_not_raise


def test_list_value() -> None:
Expand Down
3 changes: 1 addition & 2 deletions tests/test_config_eq.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import pytest

from omegaconf import AnyNode, DictConfig, ListConfig, OmegaConf

from . import Group, User
from tests import Group, User


@pytest.mark.parametrize(
Expand Down
3 changes: 1 addition & 2 deletions tests/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

from omegaconf import DictConfig, ListConfig, OmegaConf
from omegaconf.errors import UnsupportedValueType

from . import ConcretePlugin, IllegalType, NonCopyableIllegalType, Plugin
from tests import ConcretePlugin, IllegalType, NonCopyableIllegalType, Plugin


@pytest.mark.parametrize(
Expand Down
3 changes: 1 addition & 2 deletions tests/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
MissingMandatoryValue,
OmegaConfBaseException,
)

from . import (
from tests import (
A,
Color,
ConcretePlugin,
Expand Down
3 changes: 1 addition & 2 deletions tests/test_get_full_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import pytest

from omegaconf import DictConfig, IntegerNode, OmegaConf

from . import Color
from tests import Color


@pytest.mark.parametrize(
Expand Down
3 changes: 1 addition & 2 deletions tests/test_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
ValidationError,
ValueNode,
)

from . import Color, Group
from tests import Color, Group

SKIP = object()

Expand Down
3 changes: 1 addition & 2 deletions tests/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
from omegaconf._utils import is_structured_config
from omegaconf.errors import ConfigKeyError, UnsupportedValueType
from omegaconf.nodes import IntegerNode

from . import (
from tests import (
A,
B,
C,
Expand Down
3 changes: 1 addition & 2 deletions tests/test_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
ValueNode,
)
from omegaconf.errors import UnsupportedValueType, ValidationError

from . import Color, IllegalType, User
from tests import Color, IllegalType, User


# testing valid conversions
Expand Down
9 changes: 7 additions & 2 deletions tests/test_omegaconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@
StringNode,
)
from omegaconf.errors import ConfigKeyError, UnsupportedInterpolationType

from . import Color, ConcretePlugin, IllegalType, StructuredWithMissing, does_not_raise
from tests import (
Color,
ConcretePlugin,
IllegalType,
StructuredWithMissing,
does_not_raise,
)


@pytest.mark.parametrize(
Expand Down
3 changes: 1 addition & 2 deletions tests/test_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

from omegaconf import MISSING, DictConfig, ListConfig, OmegaConf
from omegaconf._utils import get_ref_type

from . import (
from tests import (
PersonA,
PersonD,
SubscriptedDict,
Expand Down
3 changes: 1 addition & 2 deletions tests/test_to_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import pytest

from omegaconf import DictConfig, EnumNode, ListConfig, OmegaConf, _utils

from . import Enum1, User
from tests import Enum1, User


@pytest.mark.parametrize(
Expand Down
3 changes: 1 addition & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
StringNode,
)
from omegaconf.omegaconf import _node_wrap

from . import Color, ConcretePlugin, IllegalType, Plugin, User, does_not_raise
from tests import Color, ConcretePlugin, IllegalType, Plugin, User, does_not_raise


@mark.parametrize(
Expand Down

0 comments on commit 6b3e0d4

Please sign in to comment.