diff --git a/lib/iris/tests/unit/config/test_NetCDF.py b/lib/iris/tests/unit/config/test_NetCDF.py index 5b691a1dc3..7469ca8c79 100644 --- a/lib/iris/tests/unit/config/test_NetCDF.py +++ b/lib/iris/tests/unit/config/test_NetCDF.py @@ -4,41 +4,40 @@ # See LICENSE in the root of the repository for full licensing details. """Unit tests for the `iris.config.NetCDF` class.""" -# Import iris.tests first so that some things can be initialised before -# importing anything else. -import iris.tests as tests # isort:skip - +import re import warnings +import pytest + import iris.config -class Test(tests.IrisTest): - def setUp(self): - self.options = iris.config.NetCDF() +@pytest.fixture +def options(): + return iris.config.NetCDF() + + +def test_basic(options): + assert not options.conventions_override - def test_basic(self): - self.assertFalse(self.options.conventions_override) - def test_enabled(self): - self.options.conventions_override = True - self.assertTrue(self.options.conventions_override) +def test_enabled(options): + options.conventions_override = True + assert options.conventions_override - def test_bad_value(self): - # A bad value should be ignored and replaced with the default value. - bad_value = "wibble" - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - self.options.conventions_override = bad_value - self.assertFalse(self.options.conventions_override) - exp_wmsg = "Attempting to set invalid value {!r}".format(bad_value) - self.assertRegex(str(w[0].message), exp_wmsg) - def test__contextmgr(self): - with self.options.context(conventions_override=True): - self.assertTrue(self.options.conventions_override) - self.assertFalse(self.options.conventions_override) +def test_bad_value(options): + # A bad value should be ignored and replaced with the default value. + bad_value = "wibble" + with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") + options.conventions_override = bad_value + assert not options.conventions_override + exp_wmsg = "Attempting to set invalid value {!r}".format(bad_value) + assert re.match(exp_wmsg, str(w[0].message)) -if __name__ == "__main__": - tests.main() +def test__contextmgr(options): + with options.context(conventions_override=True): + assert options.conventions_override + assert not options.conventions_override