diff options
| author | Jonathan Striebel <jstriebel@users.noreply.github.com> | 2021-09-28 17:43:31 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-28 17:43:31 +0200 |
| commit | fe918fff6983df3a54bd11b968cb4ac7adc57f70 (patch) | |
| tree | 559b939315eb144534603943242ac6c60aed8c9a /tests | |
| parent | e763ba92ca73d420adfbd2d04465ab207272a47c (diff) | |
| download | astroid-git-fe918fff6983df3a54bd11b968cb4ac7adc57f70.tar.gz | |
continuing #839: Extend attrs brain to support provisional APIs (#1187)
* Extend attrs brain to support provisional APIs
See https://www.attrs.org/en/stable/api.html?highlight=field#provisional-apis
Co-authored-by: Tamir Bahar <tbahar@vdoo.com>
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/unittest_brain.py | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/tests/unittest_brain.py b/tests/unittest_brain.py index 65a3b9c2..8e962b35 100644 --- a/tests/unittest_brain.py +++ b/tests/unittest_brain.py @@ -2110,7 +2110,7 @@ class AttrsTest(unittest.TestCase): module = astroid.parse( """ import attr - from attr import attrs, attrib + from attr import attrs, attrib, field @attr.s class Foo: @@ -2140,10 +2140,31 @@ class AttrsTest(unittest.TestCase): i = Bai() i.d['answer'] = 42 + + @attr.define + class Spam: + d = field(default=attr.Factory(dict)) + + j = Spam(d=1) + j.d['answer'] = 42 + + @attr.mutable + class Eggs: + d = attr.field(default=attr.Factory(dict)) + + k = Eggs(d=1) + k.d['answer'] = 42 + + @attr.frozen + class Eggs: + d = attr.field(default=attr.Factory(dict)) + + l = Eggs(d=1) + l.d['answer'] = 42 """ ) - for name in ("f", "g", "h", "i"): + for name in ("f", "g", "h", "i", "j", "k", "l"): should_be_unknown = next(module.getattr(name)[0].infer()).getattr("d")[0] self.assertIsInstance(should_be_unknown, astroid.Unknown) |
