Passed
Pull Request — master (#87)
by
unknown
03:06
created

TestDeprecation.test_deprecation()   A

Complexity

Conditions 2

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 8
nop 1
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
# -*- coding: utf-8 -*-
2
# Copyright (C) 2018 Greenbone Networks GmbH
3
#
4
# SPDX-License-Identifier: GPL-3.0-or-later
5
#
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19
import unittest
20
import warnings
21
22
from gvm.utils import deprecation
23
24
25
class TestDeprecation(unittest.TestCase):
26
27
    def test_deprecation(self):
28
        with warnings.catch_warnings(record=True) as w:
0 ignored issues
show
Coding Style Naming introduced by
Variable name "w" doesn't conform to '[a-z_][a-z0-9_]+$' pattern ('[a-z_][a-z0-9_]+$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
29
            self.assertEqual(len(w), 0)
30
31
            warnings.simplefilter("always")
32
33
            deprecation('I am deprecated')
34
35
            self.assertEqual(len(w), 1)
36
            self.assertTrue(issubclass(w[0].category, DeprecationWarning))
37
            self.assertIn(str(w[0].message), 'I am deprecated')
38
39
40
if __name__ == '__main__':
41
    unittest.main()
42