[go: up one dir, main page]

File: test_decorators.py

package info (click to toggle)
seaborn 0.12.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 6,148 kB
  • sloc: python: 36,560; makefile: 183; javascript: 45; sh: 15
file content (25 lines) | stat: -rw-r--r-- 636 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
import inspect
from seaborn._decorators import share_init_params_with_map


def test_share_init_params_with_map():

    @share_init_params_with_map
    class Thingie:

        def map(cls, *args, **kwargs):
            return cls(*args, **kwargs)

        def __init__(self, a, b=1):
            """Make a new thingie."""
            self.a = a
            self.b = b

    thingie = Thingie.map(1, b=2)
    assert thingie.a == 1
    assert thingie.b == 2

    assert "a" in inspect.signature(Thingie.map).parameters
    assert "b" in inspect.signature(Thingie.map).parameters

    assert Thingie.map.__doc__ == Thingie.__init__.__doc__