diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-04-03 14:11:13 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-04-03 22:49:11 +0900 |
commit | af34d7169ecc45240be90ca99764474d9d2564ba (patch) | |
tree | 3901ed896bfe97eba131d0d89e4ed9edad5b24ee /tests/loader | |
parent | 01db40724a6ff0e69bdde02f5720479b1b503b3b (diff) | |
download | buildstream-af34d7169ecc45240be90ca99764474d9d2564ba.tar.gz |
_project.py: Adhere to policy on private symbols
And adjust all surrounding sources for changed symbols.
Additional details:
o Added Project.get_shell_config() to report the shell configuration,
instead of making those members all public
o Moved assertions about project specified format versions required
of plugins out of Plugin.__init__, and into Project.create_element()
and Project.create_source(), so we can keep more things private
This is a part of issue #285
Diffstat (limited to 'tests/loader')
-rw-r--r-- | tests/loader/__init__.py | 7 | ||||
-rw-r--r-- | tests/loader/basics.py | 14 | ||||
-rw-r--r-- | tests/loader/dependencies.py | 22 |
3 files changed, 23 insertions, 20 deletions
diff --git a/tests/loader/__init__.py b/tests/loader/__init__.py index c7058e729..d64b776a4 100644 --- a/tests/loader/__init__.py +++ b/tests/loader/__init__.py @@ -1,5 +1,6 @@ from buildstream._context import Context from buildstream._project import Project +from buildstream._loader import Loader # @@ -7,5 +8,7 @@ from buildstream._project import Project # be removed in favor of testing the functionality via # the CLI like in the frontend tests anyway. # -def make_project(basedir): - return Project(basedir, Context()) +def make_loader(basedir, targets): + context = Context() + project = Project(basedir, context) + return Loader(context, project, targets) diff --git a/tests/loader/basics.py b/tests/loader/basics.py index f9ae689ef..9c526a27b 100644 --- a/tests/loader/basics.py +++ b/tests/loader/basics.py @@ -4,7 +4,7 @@ import pytest from buildstream._exceptions import LoadError, LoadErrorReason from buildstream._loader import Loader from buildstream._metaelement import MetaElement -from . import make_project +from . import make_loader DATA_DIR = os.path.join( os.path.dirname(os.path.realpath(__file__)), @@ -19,7 +19,7 @@ DATA_DIR = os.path.join( def test_one_file(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(make_project(basedir), ['elements/onefile.bst']) + loader = make_loader(basedir, ['elements/onefile.bst']) element = loader.load()[0] @@ -31,7 +31,7 @@ def test_one_file(datafiles): def test_missing_file(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(make_project(basedir), ['elements/missing.bst']) + loader = make_loader(basedir, ['elements/missing.bst']) with pytest.raises(LoadError) as exc: element = loader.load()[0] @@ -43,7 +43,7 @@ def test_missing_file(datafiles): def test_invalid_reference(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(make_project(basedir), ['elements/badreference.bst']) + loader = make_loader(basedir, ['elements/badreference.bst']) with pytest.raises(LoadError) as exc: element = loader.load()[0] @@ -55,7 +55,7 @@ def test_invalid_reference(datafiles): def test_invalid_yaml(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(make_project(basedir), ['elements/badfile.bst']) + loader = make_loader(basedir, ['elements/badfile.bst']) with pytest.raises(LoadError) as exc: element = loader.load()[0] @@ -70,7 +70,7 @@ def test_fail_fullpath_target(datafiles): fullpath = os.path.join(basedir, 'elements', 'onefile.bst') with pytest.raises(LoadError) as exc: - loader = Loader(make_project(basedir), [fullpath]) + loader = make_loader(basedir, [fullpath]) assert (exc.value.reason == LoadErrorReason.INVALID_DATA) @@ -79,7 +79,7 @@ def test_fail_fullpath_target(datafiles): def test_invalid_key(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(make_project(basedir), ['elements/invalidkey.bst']) + loader = make_loader(basedir, ['elements/invalidkey.bst']) with pytest.raises(LoadError) as exc: element = loader.load()[0] diff --git a/tests/loader/dependencies.py b/tests/loader/dependencies.py index 19bab3fd5..c8fa1b629 100644 --- a/tests/loader/dependencies.py +++ b/tests/loader/dependencies.py @@ -4,7 +4,7 @@ import pytest from buildstream._exceptions import LoadError, LoadErrorReason from buildstream._loader import Loader from buildstream._metaelement import MetaElement -from . import make_project +from . import make_loader DATA_DIR = os.path.join( os.path.dirname(os.path.realpath(__file__)), @@ -19,7 +19,7 @@ DATA_DIR = os.path.join( def test_two_files(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(make_project(basedir), ['elements/target.bst']) + loader = make_loader(basedir, ['elements/target.bst']) element = loader.load()[0] assert(isinstance(element, MetaElement)) @@ -35,7 +35,7 @@ def test_two_files(datafiles): def test_shared_dependency(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(make_project(basedir), ['elements/shareddeptarget.bst']) + loader = make_loader(basedir, ['elements/shareddeptarget.bst']) element = loader.load()[0] # Toplevel is 'pony' with 2 dependencies @@ -78,7 +78,7 @@ def test_shared_dependency(datafiles): def test_dependency_dict(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(make_project(basedir), ['elements/target-depdict.bst']) + loader = make_loader(basedir, ['elements/target-depdict.bst']) element = loader.load()[0] assert(isinstance(element, MetaElement)) @@ -93,7 +93,7 @@ def test_dependency_dict(datafiles): @pytest.mark.datafiles(DATA_DIR) def test_invalid_dependency_declaration(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(make_project(basedir), ['elements/invaliddep.bst']) + loader = make_loader(basedir, ['elements/invaliddep.bst']) with pytest.raises(LoadError) as exc: element = loader.load()[0] @@ -104,7 +104,7 @@ def test_invalid_dependency_declaration(datafiles): @pytest.mark.datafiles(DATA_DIR) def test_circular_dependency(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(make_project(basedir), ['elements/circulartarget.bst']) + loader = make_loader(basedir, ['elements/circulartarget.bst']) with pytest.raises(LoadError) as exc: element = loader.load()[0] @@ -115,7 +115,7 @@ def test_circular_dependency(datafiles): @pytest.mark.datafiles(DATA_DIR) def test_invalid_dependency_type(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(make_project(basedir), ['elements/invaliddeptype.bst']) + loader = make_loader(basedir, ['elements/invaliddeptype.bst']) with pytest.raises(LoadError) as exc: element = loader.load()[0] @@ -126,7 +126,7 @@ def test_invalid_dependency_type(datafiles): @pytest.mark.datafiles(DATA_DIR) def test_build_dependency(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(make_project(basedir), ['elements/builddep.bst']) + loader = make_loader(basedir, ['elements/builddep.bst']) element = loader.load()[0] assert(isinstance(element, MetaElement)) @@ -142,7 +142,7 @@ def test_build_dependency(datafiles): @pytest.mark.datafiles(DATA_DIR) def test_runtime_dependency(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(make_project(basedir), ['elements/runtimedep.bst']) + loader = make_loader(basedir, ['elements/runtimedep.bst']) element = loader.load()[0] assert(isinstance(element, MetaElement)) @@ -158,7 +158,7 @@ def test_runtime_dependency(datafiles): @pytest.mark.datafiles(DATA_DIR) def test_build_runtime_dependency(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(make_project(basedir), ['elements/target.bst']) + loader = make_loader(basedir, ['elements/target.bst']) element = loader.load()[0] assert(isinstance(element, MetaElement)) @@ -175,7 +175,7 @@ def test_build_runtime_dependency(datafiles): @pytest.mark.datafiles(DATA_DIR) def test_all_dependency(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(make_project(basedir), ['elements/alldep.bst']) + loader = make_loader(basedir, ['elements/alldep.bst']) element = loader.load()[0] assert(isinstance(element, MetaElement)) |