aboutsummaryrefslogtreecommitdiff
path: root/tests/functional/d/deprecated/deprecated_methods_py38.py
blob: 35ec88f5a38705524ce8e29acdd14a1d745a7e46 (plain)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
""" Functional tests for method deprecation. """
# pylint: disable=missing-docstring, super-init-not-called, not-callable
import base64
import inspect
import logging
import nntplib
import unittest
import xml.etree.ElementTree


class MyTest(unittest.TestCase):
    def test(self):
        self.assert_(True)  # [deprecated-method]

xml.etree.ElementTree.Element('tag').getchildren()  # [deprecated-method]
xml.etree.ElementTree.Element('tag').getiterator()  # [deprecated-method]
nntplib.NNTP(None).xpath(None) # [deprecated-method]


inspect.getargspec(None) # [deprecated-method]
logging.warn("a") # [deprecated-method]
base64.encodestring("42") # [deprecated-method]
base64.decodestring("42") # [deprecated-method]


class SuperCrash(unittest.TestCase):

    def __init__(self):
        # should not crash.
        super()()

xml.etree.ElementTree.iterparse(None)


class Tests(unittest.TestCase):

    def test_foo(self):
        self.assertEquals(2 + 2, 4)  # [deprecated-method]
        self.assertNotEquals(2 + 2, 4)  # [deprecated-method]
        self.assertAlmostEquals(2 + 2, 4)  # [deprecated-method]
        self.assertNotAlmostEquals(2 + 2, 4)  # [deprecated-method]
        self.assert_("abc" == "2")  # [deprecated-method]

        self.assertRaisesRegex(ValueError, "exception")
        self.assertRegex("something", r".+")


class Deprecated:  # pylint: disable=too-few-public-methods
    deprecated_method = logging.warn


d = Deprecated()
d.deprecated_method()  # [deprecated-method]