summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarc Mueller <30130371+cdce8p@users.noreply.github.com>2023-04-25 19:50:46 +0200
committerGitHub <noreply@github.com>2023-04-25 19:50:46 +0200
commit310b62ad450527859a8b59c385aeca35663560fb (patch)
tree8c8eb9a7366a0327ade4af9e83c7309b77f9f6cc /tests
parent08ed4136d83ba88d1e605e4afad71a5420396eec (diff)
downloadastroid-git-310b62ad450527859a8b59c385aeca35663560fb.tar.gz
Remove deprecated doc attribute (#2154)
Diffstat (limited to 'tests')
-rw-r--r--tests/brain/test_brain.py3
-rw-r--r--tests/test_builder.py12
-rw-r--r--tests/test_inference.py3
-rw-r--r--tests/test_nodes.py6
-rw-r--r--tests/test_raw_building.py6
-rw-r--r--tests/test_scoped_nodes.py93
6 files changed, 0 insertions, 123 deletions
diff --git a/tests/brain/test_brain.py b/tests/brain/test_brain.py
index 3fd135db..00a023dd 100644
--- a/tests/brain/test_brain.py
+++ b/tests/brain/test_brain.py
@@ -1777,9 +1777,6 @@ class TestFunctoolsPartial:
assert isinstance(partial, objects.PartialFunction)
assert isinstance(partial.doc_node, nodes.Const)
assert partial.doc_node.value == "Docstring"
- with pytest.warns(DeprecationWarning) as records:
- assert partial.doc == "Docstring"
- assert len(records) == 1
assert partial.lineno == 3
assert partial.col_offset == 0
diff --git a/tests/test_builder.py b/tests/test_builder.py
index b4a0c464..ff83ecea 100644
--- a/tests/test_builder.py
+++ b/tests/test_builder.py
@@ -751,9 +751,6 @@ class FileBuildTest(unittest.TestCase):
"""Test base properties and method of an astroid module."""
module = self.module
self.assertEqual(module.name, "data.module")
- with pytest.warns(DeprecationWarning) as records:
- self.assertEqual(module.doc, "test module for astroid\n")
- assert len(records) == 1
assert isinstance(module.doc_node, nodes.Const)
self.assertEqual(module.doc_node.value, "test module for astroid\n")
self.assertEqual(module.fromlineno, 0)
@@ -797,9 +794,6 @@ class FileBuildTest(unittest.TestCase):
module = self.module
function = module["global_access"]
self.assertEqual(function.name, "global_access")
- with pytest.warns(DeprecationWarning) as records:
- self.assertEqual(function.doc, "function test")
- assert len(records)
assert isinstance(function.doc_node, nodes.Const)
self.assertEqual(function.doc_node.value, "function test")
self.assertEqual(function.fromlineno, 11)
@@ -824,9 +818,6 @@ class FileBuildTest(unittest.TestCase):
module = self.module
klass = module["YO"]
self.assertEqual(klass.name, "YO")
- with pytest.warns(DeprecationWarning) as records:
- self.assertEqual(klass.doc, "hehe\n haha")
- assert len(records) == 1
assert isinstance(klass.doc_node, nodes.Const)
self.assertEqual(klass.doc_node.value, "hehe\n haha")
self.assertEqual(klass.fromlineno, 25)
@@ -882,9 +873,6 @@ class FileBuildTest(unittest.TestCase):
method = klass2["method"]
self.assertEqual(method.name, "method")
self.assertEqual([n.name for n in method.args.args], ["self"])
- with pytest.warns(DeprecationWarning) as records:
- self.assertEqual(method.doc, "method\n test")
- assert len(records) == 1
assert isinstance(method.doc_node, nodes.Const)
self.assertEqual(method.doc_node.value, "method\n test")
self.assertEqual(method.fromlineno, 48)
diff --git a/tests/test_inference.py b/tests/test_inference.py
index cdb61918..3de2c17b 100644
--- a/tests/test_inference.py
+++ b/tests/test_inference.py
@@ -6440,9 +6440,6 @@ def test_property_docstring() -> None:
assert isinstance(inferred, objects.Property)
assert isinstance(inferred.doc_node, nodes.Const)
assert inferred.doc_node.value == "Docstring"
- with pytest.warns(DeprecationWarning) as records:
- assert inferred.doc == "Docstring"
- assert len(records) == 1
def test_recursion_error_inferring_builtin_containers() -> None:
diff --git a/tests/test_nodes.py b/tests/test_nodes.py
index aabd2611..6303bbef 100644
--- a/tests/test_nodes.py
+++ b/tests/test_nodes.py
@@ -1535,9 +1535,6 @@ def test_get_doc() -> None:
"""
)
node: nodes.FunctionDef = astroid.extract_node(code) # type: ignore[assignment]
- with pytest.warns(DeprecationWarning) as records:
- assert node.doc == "Docstring"
- assert len(records) == 1
assert isinstance(node.doc_node, nodes.Const)
assert node.doc_node.value == "Docstring"
assert node.doc_node.lineno == 2
@@ -1553,9 +1550,6 @@ def test_get_doc() -> None:
"""
)
node = astroid.extract_node(code)
- with pytest.warns(DeprecationWarning) as records:
- assert node.doc is None
- assert len(records) == 1
assert node.doc_node is None
diff --git a/tests/test_raw_building.py b/tests/test_raw_building.py
index 153b76ec..093e003c 100644
--- a/tests/test_raw_building.py
+++ b/tests/test_raw_building.py
@@ -50,17 +50,11 @@ class RawBuildingTC(unittest.TestCase):
def test_build_class(self) -> None:
node = build_class("MyClass")
self.assertEqual(node.name, "MyClass")
- with pytest.warns(DeprecationWarning) as records:
- self.assertEqual(node.doc, None)
- assert len(records) == 1
self.assertEqual(node.doc_node, None)
def test_build_function(self) -> None:
node = build_function("MyFunction")
self.assertEqual(node.name, "MyFunction")
- with pytest.warns(DeprecationWarning) as records:
- self.assertEqual(node.doc, None)
- assert len(records) == 1
self.assertEqual(node.doc_node, None)
def test_build_function_args(self) -> None:
diff --git a/tests/test_scoped_nodes.py b/tests/test_scoped_nodes.py
index e169dc66..b8c55f67 100644
--- a/tests/test_scoped_nodes.py
+++ b/tests/test_scoped_nodes.py
@@ -13,7 +13,6 @@ import os
import sys
import textwrap
import unittest
-import warnings
from functools import partial
from typing import Any
@@ -991,9 +990,6 @@ class ClassNodeTest(ModuleLoader, unittest.TestCase):
self.assertEqual(
len(cls.getattr("__doc__")), 1, (cls, cls.getattr("__doc__"))
)
- with pytest.warns(DeprecationWarning) as records:
- self.assertEqual(cls.getattr("__doc__")[0].value, cls.doc)
- assert len(records) == 1
self.assertEqual(cls.getattr("__doc__")[0].value, cls.doc_node.value)
self.assertEqual(len(cls.getattr("__module__")), 4)
self.assertEqual(len(cls.getattr("__dict__")), 1)
@@ -2849,92 +2845,3 @@ class TestFrameNodes:
assert module.body[1].value.locals["x"][0].frame() == module
assert module.body[1].value.locals["x"][0].frame(future=True) == module
-
-
-def test_deprecation_of_doc_attribute() -> None:
- code = textwrap.dedent(
- """\
- def func():
- "Docstring"
- return 1
- """
- )
- node: nodes.FunctionDef = extract_node(code) # type: ignore[assignment]
- with pytest.warns(DeprecationWarning) as records:
- assert node.doc == "Docstring"
- assert len(records) == 1
- with pytest.warns(DeprecationWarning) as records:
- node.doc = None
- assert len(records) == 1
-
- code = textwrap.dedent(
- """\
- class MyClass():
- '''Docstring'''
- """
- )
- node: nodes.ClassDef = extract_node(code) # type: ignore[assignment]
- with pytest.warns(DeprecationWarning) as records:
- assert node.doc == "Docstring"
- assert len(records) == 1
- with pytest.warns(DeprecationWarning) as records:
- node.doc = None
- assert len(records) == 1
-
- code = textwrap.dedent(
- """\
- '''Docstring'''
- """
- )
- node = parse(code)
- with pytest.warns(DeprecationWarning) as records:
- assert node.doc == "Docstring"
- assert len(records) == 1
- with pytest.warns(DeprecationWarning) as records:
- node.doc = None
- assert len(records) == 1
-
- # If 'doc' isn't passed to Module, ClassDef, FunctionDef,
- # no DeprecationWarning should be raised
- doc_node = nodes.Const("Docstring")
- with warnings.catch_warnings():
- # Modify warnings filter to raise error for DeprecationWarning
- warnings.simplefilter("error", DeprecationWarning)
- node_module = nodes.Module(name="MyModule")
- node_module.postinit(body=[], doc_node=doc_node)
- assert node_module.doc_node == doc_node
- node_class = nodes.ClassDef(
- name="MyClass",
- lineno=0,
- col_offset=0,
- end_lineno=0,
- end_col_offset=0,
- parent=nodes.Unknown(),
- )
- node_class.postinit(bases=[], body=[], decorators=[], doc_node=doc_node)
- assert node_class.doc_node == doc_node
- node_func = nodes.FunctionDef(
- name="MyFunction",
- lineno=0,
- col_offset=0,
- parent=node_module,
- end_lineno=0,
- end_col_offset=0,
- )
- node_func.postinit(
- args=nodes.Arguments(parent=node_func, vararg=None, kwarg=None),
- body=[],
- doc_node=doc_node,
- )
- assert node_func.doc_node == doc_node
-
- # Test 'doc' attribute if only 'doc_node' is passed
- with pytest.warns(DeprecationWarning) as records:
- assert node_module.doc == "Docstring"
- assert len(records) == 1
- with pytest.warns(DeprecationWarning) as records:
- assert node_class.doc == "Docstring"
- assert len(records) == 1
- with pytest.warns(DeprecationWarning) as records:
- assert node_func.doc == "Docstring"
- assert len(records) == 1