File size: 1,217 Bytes
065fee7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import unittest
import sys
from inspect import getfullargspec

from wrapt import formatargspec

class TestFormatargspec38(unittest.TestCase):

    def assertFormatEqual(self, func, ref):
        formatted = formatargspec(*getfullargspec(func))
        self.assertEqual(formatted, ref)

    def test_formatargspec(self):
        # exemples from https://www.python.org/dev/peps/pep-0570/
        def name1(p1, p2, /, p_or_kw, *, kw): pass
        self.assertFormatEqual(name1, '(p1, p2, p_or_kw, *, kw)')

        def name2(p1, p2=None, /, p_or_kw=None, *, kw): pass
        self.assertFormatEqual(name2, '(p1, p2=None, p_or_kw=None, *, kw)')

        def name3(p1, p2=None, /, *, kw): pass
        self.assertFormatEqual(name3, '(p1, p2=None, *, kw)')

        def name4(p1, p2=None, /): pass
        self.assertFormatEqual(name4, '(p1, p2=None)')

        def name5(p1, p2, /, p_or_kw): pass
        self.assertFormatEqual(name5, '(p1, p2, p_or_kw)')

        def name6(p1, p2, /): pass
        self.assertFormatEqual(name6, '(p1, p2)')

        def name7(p_or_kw, *, kw): pass
        self.assertFormatEqual(name7, '(p_or_kw, *, kw)')

        def name8(*, kw): pass
        self.assertFormatEqual(name8, '(*, kw)')