| 1 | import warnings |
| 2 | |
| 3 | from deprecated import deprecated |
| 4 | |
| 5 | |
| 6 | class MyDeprecationWarning(DeprecationWarning): |
| 7 | """ My DeprecationWarning """ |
| 8 | |
| 9 | |
| 10 | class DeprecatedIn26(MyDeprecationWarning): |
| 11 | """ deprecated in 2.6 """ |
| 12 | |
| 13 | |
| 14 | class DeprecatedIn30(MyDeprecationWarning): |
| 15 | """ deprecated in 3.0 """ |
| 16 | |
| 17 | |
| 18 | @deprecated(category=DeprecatedIn26, reason="deprecated function") |
| 19 | def foo(): |
| 20 | print("foo") |
| 21 | |
| 22 | |
| 23 | @deprecated(category=DeprecatedIn30, reason="deprecated function") |
| 24 | def bar(): |
| 25 | print("bar") |
| 26 | |
| 27 | |
| 28 | if __name__ == '__main__': |
| 29 | warnings.filterwarnings("ignore", category=DeprecatedIn30) |
| 30 | foo() |
| 31 | bar() |