Add tests for dataclasses (#4967)
* Add tests for dataclasses
This closes #4963 and is based on the fix in PyCQA/astroid#1165
diff --git a/tests/functional/d/dataclass_with_default_factory.py b/tests/functional/d/dataclass_with_default_factory.py
index 8f24d5e..db392d8 100644
--- a/tests/functional/d/dataclass_with_default_factory.py
+++ b/tests/functional/d/dataclass_with_default_factory.py
@@ -4,6 +4,7 @@
# - https://github.com/PyCQA/pylint/issues/2698
from dataclasses import dataclass, field
import dataclasses as dc
+from typing import cast
@dataclass
@@ -41,3 +42,9 @@
Test2.int_prop["key"] = "value" # [unsupported-assignment-operation]
+
+
+@dc.dataclass
+class TEST3:
+ """Test dataclass that puts call to field() in another function call"""
+ attribute: int = cast(int, field(default_factory=dict))
diff --git a/tests/functional/d/dataclass_with_default_factory.txt b/tests/functional/d/dataclass_with_default_factory.txt
index c33a7d3..af789b1 100644
--- a/tests/functional/d/dataclass_with_default_factory.txt
+++ b/tests/functional/d/dataclass_with_default_factory.txt
@@ -1,2 +1,2 @@
-not-an-iterable:39:9::Non-iterable value Test2.int_prop is used in an iterating context:HIGH
-unsupported-assignment-operation:43:0::'Test2.int_prop' does not support item assignment:HIGH
+not-an-iterable:40:9::Non-iterable value Test2.int_prop is used in an iterating context:HIGH
+unsupported-assignment-operation:44:0::'Test2.int_prop' does not support item assignment:HIGH