summaryrefslogtreecommitdiff
path: root/tests/functional/n/namedtuple_member_inference.py
blob: 09dc6dd445c57d672023d9d14bfd1854afc3c7fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"""Test namedtuple attributes.

Regression test for:
https://bitbucket.org/logilab/pylint/issue/93/pylint-crashes-on-namedtuple-attribute
"""
from collections import namedtuple


Thing = namedtuple('Thing', ())

Fantastic = namedtuple('Fantastic', ['foo'])

def test():
    """Test member access in named tuples."""
    print(Thing.x)  # [no-member]
    fan = Fantastic(1)
    print(fan.foo)
    # Should not raise protected-access.
    fan2 = fan._replace(foo=2)
    print(fan2.foo)