From 27aac095bdb6b0025c989572789a1f98d8d89b3c Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Mon, 6 Nov 2017 18:15:33 +0900 Subject: Refactoring: Move exceptions module to be private Hide all of buildstream's internal exceptions from the API surface. --- buildstream/__init__.py | 4 - buildstream/_artifactcache/artifactcache.py | 3 +- buildstream/_artifactcache/ostreecache.py | 2 +- buildstream/_artifactcache/tarcache.py | 2 +- buildstream/_exceptions.py | 170 ++++++++++++++++++++++++++++ buildstream/_frontend/main.py | 4 +- buildstream/_frontend/widget.py | 2 +- buildstream/_loader.py | 2 +- buildstream/_options/optionbool.py | 2 +- buildstream/_options/optionenum.py | 2 +- buildstream/_options/optionflags.py | 2 +- buildstream/_options/optionpool.py | 2 +- buildstream/_ostree.py | 2 +- buildstream/_pipeline.py | 4 +- buildstream/_platform/linux.py | 2 +- buildstream/_platform/platform.py | 2 +- buildstream/_platform/unix.py | 2 +- buildstream/_plugincontext.py | 2 +- buildstream/_scheduler/job.py | 2 +- buildstream/_variables.py | 2 +- buildstream/_yaml.py | 4 +- buildstream/context.py | 2 +- buildstream/element.py | 3 +- buildstream/exceptions.py | 157 ------------------------- buildstream/plugin.py | 3 +- buildstream/project.py | 2 +- buildstream/sandbox/_mount.py | 2 +- buildstream/sandbox/_sandboxchroot.py | 2 +- buildstream/sandbox/sandbox.py | 2 +- buildstream/source.py | 3 +- buildstream/utils.py | 2 +- tests/artifactcache/tar.py | 2 +- tests/context/context.py | 2 +- tests/format/assertion.py | 2 +- tests/format/listdirectiveerrors.py | 2 +- tests/format/optionarch.py | 2 +- tests/format/optionbool.py | 2 +- tests/format/optioneltmask.py | 2 +- tests/format/optionenum.py | 2 +- tests/format/optionexports.py | 2 +- tests/format/optionflags.py | 2 +- tests/format/options.py | 2 +- tests/format/projectoverrides.py | 2 +- tests/loader/basics.py | 2 +- tests/loader/dependencies.py | 2 +- tests/plugins/basics.py | 2 +- tests/plugins/pipeline.py | 3 +- tests/project/project.py | 2 +- tests/testutils/runcli.py | 2 +- tests/testutils/site.py | 11 +- tests/yaml/yaml.py | 2 +- 51 files changed, 228 insertions(+), 219 deletions(-) create mode 100644 buildstream/_exceptions.py delete mode 100644 buildstream/exceptions.py diff --git a/buildstream/__init__.py b/buildstream/__init__.py index 3d800610e..bb7a338a4 100644 --- a/buildstream/__init__.py +++ b/buildstream/__init__.py @@ -18,10 +18,6 @@ # Authors: # Tristan Van Berkom -# Exceptions and utilities first -from .exceptions import PluginError, LoadError, LoadErrorReason, \ - ImplError, ProgramNotFoundError, PlatformError, SandboxError - # Core components from .context import Context from .project import Project diff --git a/buildstream/_artifactcache/artifactcache.py b/buildstream/_artifactcache/artifactcache.py index 246a7691d..66e6520c9 100644 --- a/buildstream/_artifactcache/artifactcache.py +++ b/buildstream/_artifactcache/artifactcache.py @@ -21,7 +21,8 @@ import os from collections import Mapping -from .. import utils, ImplError +from .._exceptions import ImplError +from .. import utils from .. import _yaml diff --git a/buildstream/_artifactcache/ostreecache.py b/buildstream/_artifactcache/ostreecache.py index 85ad3a4cf..d958c0bc5 100644 --- a/buildstream/_artifactcache/ostreecache.py +++ b/buildstream/_artifactcache/ostreecache.py @@ -24,7 +24,7 @@ import string import tempfile from .. import _ostree, utils -from ..exceptions import _ArtifactError +from .._exceptions import _ArtifactError from ..element import _KeyStrength from .._ostree import OSTreeError diff --git a/buildstream/_artifactcache/tarcache.py b/buildstream/_artifactcache/tarcache.py index 74ba0b3a0..5f28dcb41 100644 --- a/buildstream/_artifactcache/tarcache.py +++ b/buildstream/_artifactcache/tarcache.py @@ -26,7 +26,7 @@ import subprocess from .. import utils from ..element import _KeyStrength from .._message import Message, MessageType -from ..exceptions import _ArtifactError, ProgramNotFoundError +from .._exceptions import _ArtifactError, ProgramNotFoundError from . import ArtifactCache diff --git a/buildstream/_exceptions.py b/buildstream/_exceptions.py new file mode 100644 index 000000000..c1deee786 --- /dev/null +++ b/buildstream/_exceptions.py @@ -0,0 +1,170 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 Codethink Limited +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library. If not, see . +# +# Authors: +# Tristan Van Berkom + +from enum import Enum + + +# The last raised exception, this is used in test cases only +_last_exception = None + + +def _get_last_exception(): + global _last_exception + + le = _last_exception + _last_exception = None + return le + + +# BstError is an internal base exception class for BuildSream +# exceptions. +# +# The sole purpose of using the base class is to add additional +# context to exceptions raised by plugins in child tasks, this +# context can then be communicated back to the main process. +# +class _BstError(Exception): + + def __init__(self, message): + global _last_exception + + super(_BstError, self).__init__(message) + + # The build sandbox in which the error occurred, if the + # error occurred at element assembly time. + # + self.sandbox = None + + # Hold on to the last raised exception for testing purposes + _last_exception = self + + +# PluginError +# +# Raised on plugin related errors. +# +# This exception is raised either by the plugin loading process, +# or by the base :class:`.Plugin` element itself. +# +class PluginError(_BstError): + pass + + +# LoadErrorReason +# +# Describes the reason why a :class:`.LoadError` was raised. +# +class LoadErrorReason(Enum): + + # A file was not found. + MISSING_FILE = 1 + + # The parsed data was not valid YAML. + INVALID_YAML = 2 + + # Data was malformed, a value was not of the expected type, etc + INVALID_DATA = 3 + + # An error occurred during YAML dictionary composition. + # + # This can happen by overriding a value with a new differently typed + # value, or by overwriting some named value when that was not allowed. + ILLEGAL_COMPOSITE = 4 + + # An circular dependency chain was detected + CIRCULAR_DEPENDENCY = 5 + + # A variable could not be resolved. This can happen if your project + # has cyclic dependencies in variable declarations, or, when substituting + # a string which refers to an undefined variable. + UNRESOLVED_VARIABLE = 6 + + # BuildStream does not support the required project format version + UNSUPPORTED_PROJECT = 7 + + # A conditional expression failed to resolve + EXPRESSION_FAILED = 8 + + # An assertion was intentionally encoded into project YAML + USER_ASSERTION = 9 + + # A list composition directive did not apply to any underlying list + TRAILING_LIST_DIRECTIVE = 10 + + +# LoadError +# +# Raised while loading some YAML. +# +# This exception is raised when loading or parsing YAML, or when +# interpreting project YAML +# +class LoadError(_BstError): + def __init__(self, reason, message): + super(LoadError, self).__init__(message) + + # The :class:`.LoadErrorReason` for which this exception was raised + # + self.reason = reason + + +# ImplError +# +# Raised when a :class:`.Source` or :class:`.Element` plugin fails to +# implement a mandatory method +# +class ImplError(_BstError): + pass + + +# ProgramNotFoundError +# +# Raised if a required program is not found +# +# BuildStream requires various software to exist on the host for +# it to work correctly. This exception is thrown if that software +# can not be found. E.g. The :class:`.Sandbox` class expects that +# bubblewrap is installed for it to work. +# +class ProgramNotFoundError(_BstError): + pass + + +# PlatformError +# +# Raised if the current platform is not supported. +class PlatformError(_BstError): + pass + + +# SandboxError +# +# Raised when errors are encountered by the sandbox implementation +# +class SandboxError(_BstError): + pass + + +# ArtifactError +# +# Raised when errors are encountered in the artifact caches +# +class _ArtifactError(_BstError): + pass diff --git a/buildstream/_frontend/main.py b/buildstream/_frontend/main.py index 12ed727ab..662f267cb 100644 --- a/buildstream/_frontend/main.py +++ b/buildstream/_frontend/main.py @@ -25,10 +25,10 @@ from contextlib import contextmanager from blessings import Terminal # Import buildstream public symbols -from .. import Context, Project, Scope, Consistency, LoadError +from .. import Context, Project, Scope, Consistency # Import various buildstream internals -from ..exceptions import _BstError +from .._exceptions import _BstError, LoadError from .._message import MessageType, unconditional_messages from .._pipeline import Pipeline, PipelineError from .._scheduler import Scheduler diff --git a/buildstream/_frontend/widget.py b/buildstream/_frontend/widget.py index e09f3d900..1d7a5ecc8 100644 --- a/buildstream/_frontend/widget.py +++ b/buildstream/_frontend/widget.py @@ -30,7 +30,7 @@ from mmap import mmap from .. import utils, _yaml from ..plugin import _plugin_lookup from .._message import MessageType -from .. import ImplError +from .._exceptions import ImplError from .. import Element, Scope, Consistency from . import Profile diff --git a/buildstream/_loader.py b/buildstream/_loader.py index 788a5c98e..9a3fd5eaa 100644 --- a/buildstream/_loader.py +++ b/buildstream/_loader.py @@ -23,7 +23,7 @@ import copy from functools import cmp_to_key from collections import Mapping, namedtuple -from . import LoadError, LoadErrorReason +from ._exceptions import LoadError, LoadErrorReason from . import _yaml from ._yaml import CompositeTypeError diff --git a/buildstream/_options/optionbool.py b/buildstream/_options/optionbool.py index a4619504d..db01340e4 100644 --- a/buildstream/_options/optionbool.py +++ b/buildstream/_options/optionbool.py @@ -19,7 +19,7 @@ # Tristan Van Berkom from .. import _yaml -from .. import LoadError, LoadErrorReason +from .._exceptions import LoadError, LoadErrorReason from .option import Option, OPTION_SYMBOLS diff --git a/buildstream/_options/optionenum.py b/buildstream/_options/optionenum.py index 5c4db7ddf..2ba8552d7 100644 --- a/buildstream/_options/optionenum.py +++ b/buildstream/_options/optionenum.py @@ -19,7 +19,7 @@ # Tristan Van Berkom from .. import _yaml -from .. import LoadError, LoadErrorReason +from .._exceptions import LoadError, LoadErrorReason from .option import Option, OPTION_SYMBOLS diff --git a/buildstream/_options/optionflags.py b/buildstream/_options/optionflags.py index 25d2d1c59..49ec70d85 100644 --- a/buildstream/_options/optionflags.py +++ b/buildstream/_options/optionflags.py @@ -19,7 +19,7 @@ # Tristan Van Berkom from .. import _yaml -from .. import LoadError, LoadErrorReason +from .._exceptions import LoadError, LoadErrorReason from .option import Option, OPTION_SYMBOLS diff --git a/buildstream/_options/optionpool.py b/buildstream/_options/optionpool.py index c2374c542..adca24a2d 100644 --- a/buildstream/_options/optionpool.py +++ b/buildstream/_options/optionpool.py @@ -23,7 +23,7 @@ import jinja2 from collections import Mapping from .. import _yaml -from .. import LoadError, LoadErrorReason +from .._exceptions import LoadError, LoadErrorReason from .optionbool import OptionBool from .optionenum import OptionEnum from .optionflags import OptionFlags diff --git a/buildstream/_ostree.py b/buildstream/_ostree.py index a5029a690..8e390e94b 100644 --- a/buildstream/_ostree.py +++ b/buildstream/_ostree.py @@ -26,7 +26,7 @@ import os import subprocess from . import _site from . import utils -from .exceptions import _BstError +from ._exceptions import _BstError import gi gi.require_version('OSTree', '1.0') diff --git a/buildstream/_pipeline.py b/buildstream/_pipeline.py index edaf13318..1df57a9c1 100644 --- a/buildstream/_pipeline.py +++ b/buildstream/_pipeline.py @@ -29,12 +29,12 @@ from operator import itemgetter from tempfile import TemporaryDirectory from pluginbase import PluginBase -from .exceptions import _BstError, _ArtifactError +from ._exceptions import _BstError, _ArtifactError, ImplError, LoadError from ._message import Message, MessageType from ._elementfactory import ElementFactory from ._loader import Loader from ._sourcefactory import SourceFactory -from . import Consistency, ImplError, LoadError +from . import Consistency from . import Scope from . import _site from . import _yaml, utils diff --git a/buildstream/_platform/linux.py b/buildstream/_platform/linux.py index c94e3632d..cab9aa996 100644 --- a/buildstream/_platform/linux.py +++ b/buildstream/_platform/linux.py @@ -23,7 +23,7 @@ import sys import subprocess from .. import utils -from .. import PlatformError +from .._exceptions import PlatformError from .._message import Message, MessageType from ..sandbox import SandboxBwrap from .._artifactcache.ostreecache import OSTreeCache diff --git a/buildstream/_platform/platform.py b/buildstream/_platform/platform.py index 387abcb9a..0f3007cd9 100644 --- a/buildstream/_platform/platform.py +++ b/buildstream/_platform/platform.py @@ -23,7 +23,7 @@ import sys import platform from .. import utils -from .. import PlatformError, ProgramNotFoundError, ImplError +from .._exceptions import PlatformError, ProgramNotFoundError, ImplError class Platform(): diff --git a/buildstream/_platform/unix.py b/buildstream/_platform/unix.py index 752386bdf..8a9f6ea17 100644 --- a/buildstream/_platform/unix.py +++ b/buildstream/_platform/unix.py @@ -23,7 +23,7 @@ import sys import pathlib from .. import utils -from .. import PlatformError +from .._exceptions import PlatformError from ..sandbox import SandboxChroot from .._artifactcache.tarcache import TarCache diff --git a/buildstream/_plugincontext.py b/buildstream/_plugincontext.py index 0207136ef..3b82954ed 100644 --- a/buildstream/_plugincontext.py +++ b/buildstream/_plugincontext.py @@ -22,7 +22,7 @@ import os import inspect import pkg_resources -from .exceptions import PluginError +from ._exceptions import PluginError from . import utils diff --git a/buildstream/_scheduler/job.py b/buildstream/_scheduler/job.py index 90551b712..d8e720d9f 100644 --- a/buildstream/_scheduler/job.py +++ b/buildstream/_scheduler/job.py @@ -30,7 +30,7 @@ import multiprocessing from ruamel import yaml # BuildStream toplevel imports -from ..exceptions import _BstError +from .._exceptions import _BstError from .._message import Message, MessageType, unconditional_messages from ..plugin import _plugin_lookup from .. import _yaml, _signals, utils diff --git a/buildstream/_variables.py b/buildstream/_variables.py index dfbd8ff04..15e5ecac1 100644 --- a/buildstream/_variables.py +++ b/buildstream/_variables.py @@ -20,7 +20,7 @@ import re -from . import LoadError, LoadErrorReason +from ._exceptions import LoadError, LoadErrorReason from . import _yaml # Variables are allowed to have dashes here diff --git a/buildstream/_yaml.py b/buildstream/_yaml.py index 8aa2ec714..153e744f4 100644 --- a/buildstream/_yaml.py +++ b/buildstream/_yaml.py @@ -26,7 +26,7 @@ from contextlib import ExitStack from ruamel import yaml from ruamel.yaml.representer import SafeRepresenter, RoundTripRepresenter -from . import ImplError, LoadError, LoadErrorReason +from ._exceptions import LoadError, LoadErrorReason # We store information in the loaded yaml on a DictProvenance @@ -57,7 +57,7 @@ class Provenance(): # Abstract method def clone(self): - raise ImplError("Unimplemented clone() in Provenance") + pass # pragma: nocover # A Provenance for dictionaries, these are stored in the copy of the diff --git a/buildstream/context.py b/buildstream/context.py index a644da281..81929591a 100644 --- a/buildstream/context.py +++ b/buildstream/context.py @@ -39,7 +39,7 @@ from collections import deque, Mapping from . import _site from . import _yaml from . import utils -from . import LoadError, LoadErrorReason +from ._exceptions import LoadError, LoadErrorReason from ._profile import Topics, profile_start, profile_end diff --git a/buildstream/element.py b/buildstream/element.py index 0c121cd1c..054c75667 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -37,8 +37,7 @@ import shutil from . import _yaml from ._variables import Variables -from .exceptions import _BstError, _ArtifactError -from . import LoadError, LoadErrorReason, ImplError +from ._exceptions import _BstError, _ArtifactError, LoadError, LoadErrorReason, ImplError from . import Plugin, Consistency from .project import BST_ARTIFACT_VERSION as BST_CORE_ARTIFACT_VERSION from . import SandboxFlags diff --git a/buildstream/exceptions.py b/buildstream/exceptions.py deleted file mode 100644 index e896c0c20..000000000 --- a/buildstream/exceptions.py +++ /dev/null @@ -1,157 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2016 Codethink Limited -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library. If not, see . -# -# Authors: -# Tristan Van Berkom -""" -Exceptions -========== -""" - -from enum import Enum - - -# The last raised exception, this is used in test cases only -_last_exception = None - - -def _get_last_exception(): - global _last_exception - - le = _last_exception - _last_exception = None - return le - - -# BstError is an internal base exception class for BuildSream -# exceptions. -# -# The sole purpose of using the base class is to add additional -# context to exceptions raised by plugins in child tasks, this -# context can then be communicated back to the main process. -# -class _BstError(Exception): - - def __init__(self, message): - global _last_exception - - super(_BstError, self).__init__(message) - - # The build sandbox in which the error occurred, if the - # error occurred at element assembly time. - # - self.sandbox = None - - # Hold on to the last raised exception for testing purposes - _last_exception = self - - -class PluginError(_BstError): - """Raised on plugin related errors. - - This exception is raised either by the plugin loading process, - or by the base :class:`.Plugin` element itself. - """ - pass - - -class LoadErrorReason(Enum): - """Describes the reason why a :class:`.LoadError` was raised. - """ - - MISSING_FILE = 1 - """A file was not found.""" - - INVALID_YAML = 2 - """The parsed data was not valid YAML.""" - - INVALID_DATA = 3 - """Data was malformed, a value was not of the expected type, etc""" - - ILLEGAL_COMPOSITE = 4 - """An error occurred during YAML dictionary composition. - - This can happen by overriding a value with a new differently typed - value, or by overwriting some named value when that was not allowed. - """ - - CIRCULAR_DEPENDENCY = 5 - """An circular dependency chain was detected""" - - UNRESOLVED_VARIABLE = 6 - """A variable could not be resolved. This can happen if your project - has cyclic dependencies in variable declarations, or, when substituting - a string which refers to an undefined variable. - """ - - UNSUPPORTED_PROJECT = 7 - """BuildStream does not support the required project format version""" - - EXPRESSION_FAILED = 8 - """A conditional expression failed to resolve""" - - USER_ASSERTION = 9 - """An assertion was intentionally encoded into project YAML""" - - TRAILING_LIST_DIRECTIVE = 10 - """A list composition directive did not apply to any underlying list""" - - -class LoadError(_BstError): - """Raised while loading some YAML. - - This exception is raised when loading or parsing YAML, or when - interpreting project YAML - """ - def __init__(self, reason, message): - super(LoadError, self).__init__(message) - - self.reason = reason - """The :class:`.LoadErrorReason` for which this exception was raised - """ - - -class ImplError(_BstError): - """Raised when a :class:`.Source` or :class:`.Element` plugin fails to - implement a mandatory method""" - pass - - -class ProgramNotFoundError(_BstError): - """Raised if a required program is not found - - BuildSource requires various software to exist on the host for - it to work correctly. This exception is thrown if that software - can not be found. E.g. The :class:`.Sandbox` class expects that - bubblewrap is installed for it to work. - """ - pass - - -class PlatformError(_BstError): - """Raised if the current platform is not supported. - """ - pass - - -class SandboxError(_BstError): - """Raised when errors are encountered by the sandbox implementation""" - pass - - -class _ArtifactError(_BstError): - pass diff --git a/buildstream/plugin.py b/buildstream/plugin.py index 93bac3465..23d34ab10 100644 --- a/buildstream/plugin.py +++ b/buildstream/plugin.py @@ -77,8 +77,7 @@ from weakref import WeakValueDictionary from . import _yaml, _signals from . import utils -from . import PluginError, ImplError -from .exceptions import _BstError +from ._exceptions import PluginError, ImplError, _BstError from ._message import Message, MessageType diff --git a/buildstream/project.py b/buildstream/project.py index 66561041e..d83159711 100644 --- a/buildstream/project.py +++ b/buildstream/project.py @@ -34,7 +34,7 @@ from . import utils from . import _site from . import _yaml from ._profile import Topics, profile_start, profile_end -from . import LoadError, LoadErrorReason +from ._exceptions import LoadError, LoadErrorReason from ._options import OptionPool BST_FORMAT_VERSION = 0 diff --git a/buildstream/sandbox/_mount.py b/buildstream/sandbox/_mount.py index 472534c9e..f78d3aa3d 100644 --- a/buildstream/sandbox/_mount.py +++ b/buildstream/sandbox/_mount.py @@ -1,7 +1,7 @@ import sys from contextlib import contextmanager -from .. import SandboxError +from .._exceptions import SandboxError from .. import utils, _signals diff --git a/buildstream/sandbox/_sandboxchroot.py b/buildstream/sandbox/_sandboxchroot.py index b1c5997fa..33f991b87 100644 --- a/buildstream/sandbox/_sandboxchroot.py +++ b/buildstream/sandbox/_sandboxchroot.py @@ -27,7 +27,7 @@ import signal import subprocess from contextlib import contextmanager, ExitStack -from .. import SandboxError +from .._exceptions import SandboxError from .. import utils from .. import _signals from ._mount import Mount diff --git a/buildstream/sandbox/sandbox.py b/buildstream/sandbox/sandbox.py index 1df094c39..0dc9aa2a5 100644 --- a/buildstream/sandbox/sandbox.py +++ b/buildstream/sandbox/sandbox.py @@ -33,7 +33,7 @@ from collections import OrderedDict from contextlib import contextmanager, ExitStack from .. import utils -from .. import ImplError +from .._exceptions import ImplError from .._fuse import SafeHardlinks diff --git a/buildstream/source.py b/buildstream/source.py index bab759989..aeae41220 100644 --- a/buildstream/source.py +++ b/buildstream/source.py @@ -28,8 +28,7 @@ import shutil from contextlib import contextmanager from . import _yaml, _signals, utils -from .exceptions import _BstError -from . import ImplError, LoadError, LoadErrorReason +from ._exceptions import _BstError, ImplError, LoadError, LoadErrorReason from . import Plugin diff --git a/buildstream/utils.py b/buildstream/utils.py index 7caf107a4..637d583b0 100644 --- a/buildstream/utils.py +++ b/buildstream/utils.py @@ -38,7 +38,7 @@ import re import tempfile import pkg_resources from contextlib import contextmanager -from . import ProgramNotFoundError +from ._exceptions import ProgramNotFoundError from . import _yaml from . import _signals diff --git a/tests/artifactcache/tar.py b/tests/artifactcache/tar.py index 835c5034d..d982aab01 100644 --- a/tests/artifactcache/tar.py +++ b/tests/artifactcache/tar.py @@ -7,7 +7,7 @@ import pytest from buildstream._artifactcache.tarcache import Tar from buildstream.utils import get_host_tool -from buildstream.exceptions import ProgramNotFoundError +from buildstream._exceptions import ProgramNotFoundError # Test that it 'works' - this may be equivalent to test_archive_no_tar() diff --git a/tests/context/context.py b/tests/context/context.py index 48ce037f7..be0dd8a55 100644 --- a/tests/context/context.py +++ b/tests/context/context.py @@ -2,7 +2,7 @@ import os import pytest from buildstream import Context -from buildstream import LoadError, LoadErrorReason +from buildstream._exceptions import LoadError, LoadErrorReason from tests.testutils.site import HAVE_ROOT diff --git a/tests/format/assertion.py b/tests/format/assertion.py index ec1305081..27a3d3fc7 100644 --- a/tests/format/assertion.py +++ b/tests/format/assertion.py @@ -1,7 +1,7 @@ import os import pytest from buildstream import _yaml -from buildstream import LoadError, LoadErrorReason +from buildstream._exceptions import LoadError, LoadErrorReason from tests.testutils.runcli import cli # Project directory diff --git a/tests/format/listdirectiveerrors.py b/tests/format/listdirectiveerrors.py index 9f2cfaaca..8a5d4f152 100644 --- a/tests/format/listdirectiveerrors.py +++ b/tests/format/listdirectiveerrors.py @@ -1,7 +1,7 @@ import os import pytest from buildstream import _yaml -from buildstream import LoadError, LoadErrorReason +from buildstream._exceptions import LoadError, LoadErrorReason from tests.testutils.runcli import cli # Project directory diff --git a/tests/format/optionarch.py b/tests/format/optionarch.py index fce689800..5d28b83f2 100644 --- a/tests/format/optionarch.py +++ b/tests/format/optionarch.py @@ -2,7 +2,7 @@ import os import pytest from contextlib import contextmanager from buildstream import _yaml -from buildstream import LoadError, LoadErrorReason +from buildstream._exceptions import LoadError, LoadErrorReason from tests.testutils.runcli import cli # Project directory diff --git a/tests/format/optionbool.py b/tests/format/optionbool.py index a02ec742e..3c33a8713 100644 --- a/tests/format/optionbool.py +++ b/tests/format/optionbool.py @@ -1,7 +1,7 @@ import os import pytest from buildstream import _yaml -from buildstream import LoadError, LoadErrorReason +from buildstream._exceptions import LoadError, LoadErrorReason from tests.testutils.runcli import cli # Project directory diff --git a/tests/format/optioneltmask.py b/tests/format/optioneltmask.py index 83ccf8b6f..84c594772 100644 --- a/tests/format/optioneltmask.py +++ b/tests/format/optioneltmask.py @@ -1,7 +1,7 @@ import os import pytest from buildstream import _yaml -from buildstream import LoadError, LoadErrorReason +from buildstream._exceptions import LoadError, LoadErrorReason from tests.testutils.runcli import cli # Project directory diff --git a/tests/format/optionenum.py b/tests/format/optionenum.py index 5804a5fc1..19dd3d4af 100644 --- a/tests/format/optionenum.py +++ b/tests/format/optionenum.py @@ -1,7 +1,7 @@ import os import pytest from buildstream import _yaml -from buildstream import LoadError, LoadErrorReason +from buildstream._exceptions import LoadError, LoadErrorReason from tests.testutils.runcli import cli # Project directory diff --git a/tests/format/optionexports.py b/tests/format/optionexports.py index 849c9148e..d824f0306 100644 --- a/tests/format/optionexports.py +++ b/tests/format/optionexports.py @@ -1,7 +1,7 @@ import os import pytest from buildstream import _yaml -from buildstream import LoadError, LoadErrorReason +from buildstream._exceptions import LoadError, LoadErrorReason from tests.testutils.runcli import cli # Project directory diff --git a/tests/format/optionflags.py b/tests/format/optionflags.py index 7ad5f2485..de48ab9d1 100644 --- a/tests/format/optionflags.py +++ b/tests/format/optionflags.py @@ -1,7 +1,7 @@ import os import pytest from buildstream import _yaml -from buildstream import LoadError, LoadErrorReason +from buildstream._exceptions import LoadError, LoadErrorReason from tests.testutils.runcli import cli # Project directory diff --git a/tests/format/options.py b/tests/format/options.py index 5cb01622c..1cfea7c71 100644 --- a/tests/format/options.py +++ b/tests/format/options.py @@ -1,7 +1,7 @@ import os import pytest from buildstream import _yaml -from buildstream import LoadError, LoadErrorReason +from buildstream._exceptions import LoadError, LoadErrorReason from tests.testutils.runcli import cli # Project directory diff --git a/tests/format/projectoverrides.py b/tests/format/projectoverrides.py index 4d6eb14f5..1824ff0be 100644 --- a/tests/format/projectoverrides.py +++ b/tests/format/projectoverrides.py @@ -2,7 +2,7 @@ import os import pytest from buildstream import _yaml -from buildstream import LoadError, LoadErrorReason +from buildstream._exceptions import LoadError, LoadErrorReason from tests.testutils.runcli import cli # Project directory diff --git a/tests/loader/basics.py b/tests/loader/basics.py index 3135b4b6e..db92efb36 100644 --- a/tests/loader/basics.py +++ b/tests/loader/basics.py @@ -1,7 +1,7 @@ import os import pytest -from buildstream import LoadError, LoadErrorReason +from buildstream._exceptions import LoadError, LoadErrorReason from buildstream._loader import Loader from buildstream._metaelement import MetaElement from . import make_options diff --git a/tests/loader/dependencies.py b/tests/loader/dependencies.py index ac6ee5d4b..bd588867b 100644 --- a/tests/loader/dependencies.py +++ b/tests/loader/dependencies.py @@ -1,7 +1,7 @@ import os import pytest -from buildstream import LoadError, LoadErrorReason +from buildstream._exceptions import LoadError, LoadErrorReason from buildstream._loader import Loader from buildstream._metaelement import MetaElement from . import make_options diff --git a/tests/plugins/basics.py b/tests/plugins/basics.py index db72a29bc..993d87cec 100644 --- a/tests/plugins/basics.py +++ b/tests/plugins/basics.py @@ -4,7 +4,7 @@ import pytest from pluginbase import PluginBase from buildstream._elementfactory import ElementFactory from buildstream._sourcefactory import SourceFactory -from buildstream import PluginError +from buildstream._exceptions import PluginError DATA_DIR = os.path.join( os.path.dirname(os.path.realpath(__file__)), diff --git a/tests/plugins/pipeline.py b/tests/plugins/pipeline.py index 1d4133f9e..f5c9a0c8f 100644 --- a/tests/plugins/pipeline.py +++ b/tests/plugins/pipeline.py @@ -1,7 +1,8 @@ import os import pytest -from buildstream import Context, Project, Scope, PluginError +from buildstream import Context, Project, Scope +from buildstream._exceptions import PluginError from buildstream._pipeline import Pipeline from buildstream._platform import Platform diff --git a/tests/project/project.py b/tests/project/project.py index 15baa7d3c..430e15b11 100644 --- a/tests/project/project.py +++ b/tests/project/project.py @@ -2,7 +2,7 @@ import os import pytest from buildstream import Project, Context -from buildstream import LoadError, LoadErrorReason +from buildstream._exceptions import LoadError, LoadErrorReason DATA_DIR = os.path.join( os.path.dirname(os.path.realpath(__file__)), diff --git a/tests/testutils/runcli.py b/tests/testutils/runcli.py index 593bc9448..0336d8fd5 100644 --- a/tests/testutils/runcli.py +++ b/tests/testutils/runcli.py @@ -10,7 +10,7 @@ from buildstream._frontend.main import cli as bst_cli from buildstream import _yaml # Special private exception accessor, for test case purposes -from buildstream.exceptions import _get_last_exception +from buildstream._exceptions import _get_last_exception # Wrapper for the click.testing result diff --git a/tests/testutils/site.py b/tests/testutils/site.py index 86a300da0..79538efbf 100644 --- a/tests/testutils/site.py +++ b/tests/testutils/site.py @@ -4,24 +4,25 @@ import os import sys -from buildstream import exceptions, utils +from buildstream import utils +from buildstream._exceptions import ProgramNotFoundError try: utils.get_host_tool('bzr') HAVE_BZR = True -except exceptions.ProgramNotFoundError: +except ProgramNotFoundError: HAVE_BZR = False try: utils.get_host_tool('git') HAVE_GIT = True -except exceptions.ProgramNotFoundError: +except ProgramNotFoundError: HAVE_GIT = False try: utils.get_host_tool('ostree') HAVE_OSTREE_CLI = True -except exceptions.ProgramNotFoundError: +except ProgramNotFoundError: HAVE_OSTREE_CLI = False try: @@ -33,7 +34,7 @@ except (ImportError, ValueError): try: utils.get_host_tool('bwrap') HAVE_BWRAP = True -except exceptions.ProgramNotFoundError: +except ProgramNotFoundError: HAVE_BWRAP = False IS_LINUX = os.getenv('BST_FORCE_BACKEND', sys.platform).startswith('linux') diff --git a/tests/yaml/yaml.py b/tests/yaml/yaml.py index cf12317a9..0aae28f08 100644 --- a/tests/yaml/yaml.py +++ b/tests/yaml/yaml.py @@ -3,7 +3,7 @@ import pytest from collections import Mapping from buildstream import _yaml -from buildstream import LoadError, LoadErrorReason +from buildstream._exceptions import LoadError, LoadErrorReason DATA_DIR = os.path.join( os.path.dirname(os.path.realpath(__file__)), -- cgit v1.2.1