diff options
| author | Dylan Baker <dylan@pnwbakers.com> | 2024-01-22 15:49:44 -0800 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2024-01-25 10:01:50 -0800 |
| commit | adc8d6bae4010c06fc3b779b8d84c1c5b4a910ad (patch) | |
| tree | 7b7e810833ffd3d6c346bec7ebcf578413fc9206 /unittests/internaltests.py | |
| parent | 37883e7d5fe25f9abcc93f100655b61a0e23f8e5 (diff) | |
| download | meson-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.py | 5 |
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: |
