File: sample.py

package info (click to toggle)
python-deprecation 2.1.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 244 kB
  • sloc: python: 451; makefile: 15
file content (84 lines) | stat: -rw-r--r-- 2,238 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
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import unittest

import deprecation

__version__ = "1.5"


@deprecation.deprecated(deprecated_in="1.0", removed_in="2.0",
                        current_version=__version__,
                        details="Use the ``one`` function instead")
def won():
    """This function returns 1"""
    # Oops, it's one, not won. Let's deprecate this and get it right.
    return 1


@deprecation.deprecated(deprecated_in="1.0", removed_in="2.0",
                        current_version=__version__,
                        details="Use the ``multiline_one`` function instead.")
def multiline_bottom():
    """This function returns 1.

    Multiline Bottom. Deprecation Note is inserted at the bottom.

    This is also here to show that multiline docstrings work
    """
    return 1


@deprecation.deprecated(deprecated_in="1.0", removed_in="2.0",
                        current_version=__version__,
                        details="Use the ``one`` function instead")
def uno():
    """Esta función regresa 1

    This is Spanish for 'This function returns 1'

    This is also here to show that multiline docstrings work
    """
    return 1


def one():
    """This function returns 1"""
    return 1


@deprecation.deprecated(deprecated_in="1.0", removed_in="1.5",
                        current_version=__version__,
                        details="Why would you ever do this anyway?")
def why():
    """This isn't necessary"""
    return None


deprecation.message_location = 'top'


@deprecation.deprecated(deprecated_in="1.0", removed_in="2.0",
                        current_version=__version__,
                        details="Use the ``multiline_one`` function instead.")
def multiline_top():
    """This function returns 1.

    Multiline Top. Deprecation Note is inserted above this line. This is done
    via setting ``deprecation.message_location`` to 'top'.

    This is also here to show that multiline docstrings work
    """
    return 1


class Tests(unittest.TestCase):

    @deprecation.fail_if_not_removed
    def test_won(self):
        self.assertEqual(1, won())

    @deprecation.fail_if_not_removed
    def test_why(self):
        self.assertIsNone(why())

    def test_one(self):
        self.assertEqual(1, one())