File: test_deprecation.py

package info (click to toggle)
python-gvm 26.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 5,220 kB
  • sloc: python: 45,844; makefile: 18
file content (28 lines) | stat: -rw-r--r-- 694 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# SPDX-FileCopyrightText: 2018-2024 Greenbone AG
#
# SPDX-License-Identifier: GPL-3.0-or-later
#

import unittest
import warnings

from gvm.utils import deprecation


class TestDeprecation(unittest.TestCase):
    def test_deprecation(self):
        # pylint: disable=invalid-name
        with warnings.catch_warnings(record=True) as w:
            self.assertEqual(len(w), 0)

            warnings.simplefilter("always")

            deprecation("I am deprecated")

            self.assertEqual(len(w), 1)
            self.assertTrue(issubclass(w[0].category, DeprecationWarning))
            self.assertIn(str(w[0].message), "I am deprecated")


if __name__ == "__main__":
    unittest.main()