From 4ba1296d06f1e5d3fe1493fc4eb8a6e57433c05e Mon Sep 17 00:00:00 2001 From: Mikhail Gordeev Date: Mon, 20 Apr 2020 18:55:00 +0300 Subject: [PATCH] Bring back data_dir attribute for tests --- cloud_build/cloud_build.py | 11 ++++++++--- tests/test_integration_images.py | 5 +---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/cloud_build/cloud_build.py b/cloud_build/cloud_build.py index b6f0318..21bbf4e 100755 --- a/cloud_build/cloud_build.py +++ b/cloud_build/cloud_build.py @@ -32,6 +32,8 @@ class CB: def __init__( self, config, + *, + data_dir=None, no_tests=False, create_remote_dirs=False ) -> None: @@ -41,9 +43,12 @@ class CB: self.no_tests = no_tests self._create_remote_dirs = create_remote_dirs - data_dir = (Path(self.expand_path(os.getenv('XDG_DATA_HOME', - '~/.local/share'))) - / f'{PROG}') + if not data_dir: + data_dir = (Path(self.expand_path(os.getenv('XDG_DATA_HOME', + '~/.local/share'))) + / f'{PROG}') + else: + data_dir = Path(data_dir) self.data_dir = data_dir self.checksum_command = 'sha256sum' diff --git a/tests/test_integration_images.py b/tests/test_integration_images.py index 1b5fba1..c5b51e9 100644 --- a/tests/test_integration_images.py +++ b/tests/test_integration_images.py @@ -22,13 +22,10 @@ class TestIntegrationImages(TestCase): with ExitStack() as stack: stack.enter_context(mock.patch('subprocess.call', Call())) - stack.enter_context(mock.patch.dict( - 'os.environ', - {'XDG_DATA_HOME': cls.work_dir.as_posix()} - )) cloud_build = CB( config='tests/test_integration_images.yaml', + data_dir=(cls.work_dir / 'cloud_build').as_posix(), no_tests=True, create_remote_dirs=True, )