summaryrefslogtreecommitdiff
path: root/unittests/internaltests.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2024-01-22 15:49:44 -0800
committerDylan Baker <dylan@pnwbakers.com>2024-01-25 10:01:50 -0800
commitadc8d6bae4010c06fc3b779b8d84c1c5b4a910ad (patch)
tree7b7e810833ffd3d6c346bec7ebcf578413fc9206 /unittests/internaltests.py
parent37883e7d5fe25f9abcc93f100655b61a0e23f8e5 (diff)
downloadmeson-adc8d6bae4010c06fc3b779b8d84c1c5b4a910ad.tar.gz
interpreter: replace mock keyword argument with unittest.mock
Python provides some nifty tools for mocking, without relying on altering running code. We should use these to simplify the actual run paths and move the complicated logic into tests.
Diffstat (limited to 'unittests/internaltests.py')
-rw-r--r--unittests/internaltests.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/unittests/internaltests.py b/unittests/internaltests.py
index 945faa18b..fd843c88c 100644
--- a/unittests/internaltests.py
+++ b/unittests/internaltests.py
@@ -1662,13 +1662,16 @@ class InternalTests(unittest.TestCase):
actual = mesonbuild.environment.detect_cpu({})
self.assertEqual(actual, expected)
+ @mock.patch('mesonbuild.interpreter.Interpreter.load_root_meson_file', mock.Mock(return_value=None))
+ @mock.patch('mesonbuild.interpreter.Interpreter.sanity_check_ast', mock.Mock(return_value=None))
+ @mock.patch('mesonbuild.interpreter.Interpreter.parse_project', mock.Mock(return_value=None))
def test_interpreter_unpicklable(self) -> None:
build = mock.Mock()
build.environment = mock.Mock()
build.environment.get_source_dir = mock.Mock(return_value='')
with mock.patch('mesonbuild.interpreter.Interpreter._redetect_machines', mock.Mock()), \
self.assertRaises(mesonbuild.mesonlib.MesonBugException):
- i = mesonbuild.interpreter.Interpreter(build, mock=True)
+ i = mesonbuild.interpreter.Interpreter(build)
pickle.dumps(i)
def test_major_versions_differ(self) -> None: