Skip to content

Commit

Permalink
* tests/test_utils.py: Test exceptions raised by utils.py.
Browse files Browse the repository at this point in the history
  • Loading branch information
bje- committed Nov 21, 2024
1 parent c46d067 commit c921dd9
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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))

0 comments on commit c921dd9

Please sign in to comment.