Skip to content

Commit

Permalink
Test error handling for feature aa3f393
Browse files Browse the repository at this point in the history
  • Loading branch information
JasperCraeghs committed Jan 26, 2024
1 parent 1b97f96 commit 6719965
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from unittest import TestCase
from unittest.mock import patch

from mlx.warnings import JUnitChecker, DoxyChecker, SphinxChecker, XMLRunnerChecker, RobotChecker, WarningsPlugin
from mlx.warnings import (JUnitChecker, DoxyChecker, SphinxChecker, XMLRunnerChecker, RobotChecker, WarningsPlugin,
WarningsConfigError)

TEST_IN_DIR = Path(__file__).parent / 'test_in'

Expand All @@ -14,6 +15,11 @@ def setUp(self):
os.environ['MIN_SPHINX_WARNINGS'] = '0'
os.environ['MAX_SPHINX_WARNINGS'] = '0'

def tearDown(self):
for var in ('MIN_SPHINX_WARNINGS', 'MAX_SPHINX_WARNINGS'):
if var in os.environ:
del os.environ[var]

def test_configfile_parsing(self):
warnings = WarningsPlugin(config_file=(TEST_IN_DIR / "config_example.json"))
warnings.check('testfile.c:6: warning: group test: ignoring title "Some test functions" that does not match old title "Some freaky test functions"')
Expand All @@ -27,6 +33,14 @@ def test_configfile_parsing(self):
warnings.check('ERROR [0.000s]: test_some_error_test (something.anything.somewhere)')
self.assertEqual(warnings.return_count(), 3)

def test_configfile_parsing_missing_envvar(self):
del os.environ['MAX_SPHINX_WARNINGS']
with self.assertRaises(WarningsConfigError) as c_m:
WarningsPlugin(config_file=(TEST_IN_DIR / "config_example.json"))
self.assertEqual(
str(c_m.exception),
"Failed to find environment variable 'MAX_SPHINX_WARNINGS' for configuration value 'max'")

def _helper_exclude(self, warnings):
with patch('sys.stdout', new=StringIO()) as verbose_output:
warnings.check('testfile.c:6: warning: group test: ignoring title "Some test functions" that does not match old title "Some freaky test functions"')
Expand Down

0 comments on commit 6719965

Please sign in to comment.