From ee77a1222e95421762100ceefb1ec253976501ce Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sun, 22 Sep 2019 17:10:03 +0100 Subject: [PATCH] Further test fixes following dist_dir changes --- pythonforandroid/bootstrap.py | 2 +- pythonforandroid/toolchain.py | 2 ++ tests/test_bootstrap.py | 10 +++++----- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pythonforandroid/bootstrap.py b/pythonforandroid/bootstrap.py index 07e0776360..03925a3e01 100755 --- a/pythonforandroid/bootstrap.py +++ b/pythonforandroid/bootstrap.py @@ -96,7 +96,7 @@ def dist_dir(self): '''The dist dir at which to place the finished distribution.''' if self.distribution is None: raise BuildInterruptingException( - 'Tried to access {}.dist_dir, but {}.distribution ' + 'Internal error: tried to access {}.dist_dir, but {}.distribution ' 'is None'.format(self, self)) return self.distribution.dist_dir diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 3507f337ca..04cebfc673 100644 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -15,6 +15,7 @@ from pythonforandroid.util import BuildInterruptingException from pythonforandroid.entrypoints import main + def check_python_dependencies(): # Check if the Python requirements are installed. This appears # before the imports because otherwise they're imported elsewhere. @@ -102,6 +103,7 @@ def check_python_dependencies(): APK_SUFFIX = '.apk' + def add_boolean_option(parser, names, no_names=None, default=True, dest=None, description=None): group = parser.add_argument_group(description=description) diff --git a/tests/test_bootstrap.py b/tests/test_bootstrap.py index c6a8d018e9..02d54f0d9e 100644 --- a/tests/test_bootstrap.py +++ b/tests/test_bootstrap.py @@ -11,6 +11,7 @@ from pythonforandroid.recipe import Recipe from pythonforandroid.archs import ArchARMv7_a from pythonforandroid.build import Context +from pythonforandroid.util import BuildInterruptingException from test_graph import get_fake_recipe @@ -75,11 +76,10 @@ def test_attributes(self): self.assertEqual(bs.jni_dir, "sdl2/jni") self.assertEqual(bs.get_build_dir_name(), "sdl2-python3") - # test dist_dir error + # bs.dist_dir should raise an error if there is no distribution to query bs.distribution = None - with self.assertRaises(SystemExit) as e: + with self.assertRaises(BuildInterruptingException): bs.dist_dir - self.assertEqual(e.exception.args[0], 1) # test dist_dir success self.setUp_distribution_with_bootstrap(bs) @@ -255,8 +255,8 @@ def test_prepare_dist_dir(self, mock_ensure_dir): """ bs = Bootstrap().get_bootstrap("sdl2", self.ctx) - bs.prepare_dist_dir("fake_name") - mock_ensure_dir.assert_called_once_with(bs.dist_dir) + bs.prepare_dist_dir() + mock_ensure_dir.assert_called_once() @mock.patch("pythonforandroid.bootstrap.open", create=True) @mock.patch("pythonforandroid.util.chdir")