| Total Complexity | 12 |
| Total Lines | 63 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import warnings |
||
|
|
|||
| 2 | |||
| 3 | import pytest |
||
| 4 | |||
| 5 | import decorateme |
||
| 6 | from decorateme import CodeIncompleteError, CodeRemovedError |
||
| 7 | |||
| 8 | |||
| 9 | class TestStatus: |
||
| 10 | def test_incomplete(self): |
||
| 11 | @decorateme.status(decorateme.CodeStatus.INCOMPLETE) |
||
| 12 | def x(): |
||
| 13 | pass |
||
| 14 | |||
| 15 | with pytest.raises(CodeIncompleteError): |
||
| 16 | x() |
||
| 17 | |||
| 18 | def test_removed(self): |
||
| 19 | @decorateme.status(decorateme.CodeStatus.REMOVED) |
||
| 20 | def x(): |
||
| 21 | pass |
||
| 22 | |||
| 23 | with pytest.raises(CodeRemovedError): |
||
| 24 | x() |
||
| 25 | |||
| 26 | def test_deprecated(self): |
||
| 27 | @decorateme.status(decorateme.CodeStatus.DEPRECATED) |
||
| 28 | def x(): |
||
| 29 | pass |
||
| 30 | |||
| 31 | with pytest.warns(DeprecationWarning): |
||
| 32 | x() |
||
| 33 | |||
| 34 | def test_pending_deprecation(self): |
||
| 35 | @decorateme.status(decorateme.CodeStatus.PENDING_DEPRECATION) |
||
| 36 | def x(): |
||
| 37 | pass |
||
| 38 | |||
| 39 | with pytest.warns(PendingDeprecationWarning): |
||
| 40 | x() |
||
| 41 | |||
| 42 | def test_preview(self): |
||
| 43 | @decorateme.status(decorateme.CodeStatus.PREVIEW) |
||
| 44 | def y(): |
||
| 45 | pass |
||
| 46 | |||
| 47 | with pytest.warns(decorateme.PreviewWarning): |
||
| 48 | y() |
||
| 49 | |||
| 50 | def test_stable(self): |
||
| 51 | @decorateme.status(decorateme.CodeStatus.STABLE) |
||
| 52 | def z(): |
||
| 53 | pass |
||
| 54 | |||
| 55 | with warnings.catch_warnings(): |
||
| 56 | # https://github.com/pytest-dev/pytest/issues/9404#issue-1076710891 |
||
| 57 | warnings.simplefilter("error") |
||
| 58 | z() |
||
| 59 | |||
| 60 | |||
| 61 | if __name__ == "__main__": |
||
| 62 | pytest.main() |
||
| 63 |