From c921dd9cbb2cfffd35ec5a5252966e405df02f56 Mon Sep 17 00:00:00 2001 From: Ben Elliston Date: Thu, 21 Nov 2024 21:26:49 +1100 Subject: [PATCH] * tests/test_utils.py: Test exceptions raised by utils.py. --- tests/test_utils.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/test_utils.py b/tests/test_utils.py index b8193ce6..ff1d9a71 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -19,7 +19,7 @@ from nemo import context, scenarios, sim, utils -class TestUtils(unittest.TestCase): +class TestPlots(unittest.TestCase): """Tests for utils.py functions.""" def unlink(self, filename): @@ -82,3 +82,24 @@ def test_plot_3(self): utils.plot(self.context, filename=fname) self.assertTrue(self.exists(fname)) self.unlink(fname) + + +class TestUtils(unittest.TestCase): + """Tests for other utils.py functions.""" + + def test_plot_areas(self): + """Test error handling of unsupported category.""" + with self.assertRaises(ValueError): + utils._plot_areas(None, None, 'invalid') + + def test_plot_xlim_type(self): + """Test error handling of xlim type.""" + ctx = context.Context() + with self.assertRaises(ValueError): + utils.plot(ctx, None, xlim="wrongtype") + + def test_plot_xlim_length(self): + """Test error handling of xlim tuple length.""" + ctx = context.Context() + with self.assertRaises(ValueError): + utils.plot(ctx, None, xlim=(1, 2, 3))