| @@ 16-41 (lines=26) @@ | ||
| 13 | import aacgmv2 |
|
| 14 | ||
| 15 | ||
| 16 | class TestFutureDepWarning: |
|
| 17 | def setup(self): |
|
| 18 | # Initialize the routine to be tested |
|
| 19 | self.test_routine = None |
|
| 20 | self.test_args = [] |
|
| 21 | self.test_kwargs = {} |
|
| 22 | ||
| 23 | def teardown(self): |
|
| 24 | del self.test_routine, self.test_args, self.test_kwargs |
|
| 25 | ||
| 26 | def test_future_dep_warning(self): |
|
| 27 | """Test the implementation of FutureWarning for deprecated kwargs""" |
|
| 28 | if self.test_routine is None: |
|
| 29 | assert True |
|
| 30 | else: |
|
| 31 | with warnings.catch_warnings(record=True) as wout: |
|
| 32 | # Cause all warnings to always be triggered. |
|
| 33 | warnings.simplefilter("always") |
|
| 34 | ||
| 35 | # Trigger a warning. |
|
| 36 | self.test_routine(*self.test_args, **self.test_kwargs) |
|
| 37 | ||
| 38 | # Verify some things |
|
| 39 | assert len(wout) == 1 |
|
| 40 | assert issubclass(wout[-1].category, FutureWarning) |
|
| 41 | assert "Deprecated keyword" in str(wout[-1].message) |
|
| 42 | ||
| 43 | ||
| 44 | class TestDepConvertWarning(TestFutureDepWarning): |
|
| @@ 11-36 (lines=26) @@ | ||
| 8 | import aacgmv2 |
|
| 9 | ||
| 10 | ||
| 11 | class TestFutureDepWarning: |
|
| 12 | def setup(self): |
|
| 13 | # Initialize the routine to be tested |
|
| 14 | self.test_routine = None |
|
| 15 | self.test_args = [] |
|
| 16 | self.test_kwargs = {} |
|
| 17 | ||
| 18 | def teardown(self): |
|
| 19 | del self.test_routine, self.test_args, self.test_kwargs |
|
| 20 | ||
| 21 | def test_future_dep_warning(self): |
|
| 22 | """Test the implementation of FutureWarning for dupicate routines""" |
|
| 23 | if self.test_routine is None: |
|
| 24 | assert True |
|
| 25 | else: |
|
| 26 | with warnings.catch_warnings(record=True) as wout: |
|
| 27 | # Cause all warnings to always be triggered. |
|
| 28 | warnings.simplefilter("always") |
|
| 29 | ||
| 30 | # Trigger a warning. |
|
| 31 | self.test_routine(*self.test_args, **self.test_kwargs) |
|
| 32 | ||
| 33 | # Verify some things |
|
| 34 | assert len(wout) == 1 |
|
| 35 | assert issubclass(wout[-1].category, FutureWarning) |
|
| 36 | assert "Duplicate routine" in str(wout[-1].message) |
|
| 37 | ||
| 38 | ||
| 39 | class TestDepAACGMV2Warning(TestFutureDepWarning): |
|