Skip to content

Commit

Permalink
Remove deprecation warning from test_help
Browse files Browse the repository at this point in the history
  • Loading branch information
Jérémy Phetphoumy committed Dec 4, 2023
1 parent 0ed195a commit f5fc834
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
13 changes: 4 additions & 9 deletions tests/test_main.py
Expand Up @@ -2,7 +2,6 @@
import platform
import re
import sys
import warnings
from collections import defaultdict
from copy import deepcopy
from dataclasses import dataclass
Expand Down Expand Up @@ -2978,12 +2977,9 @@ class Bar(BaseModel):


def test_help(create_module):
# since pydoc/help access all attributes to generate their documentation,
# this triggers the deprecation warnings.
with warnings.catch_warnings():
module = create_module(
# language=Python
"""
module = create_module(
# language=Python
"""
import pydoc
from pydantic import BaseModel
Expand All @@ -2994,8 +2990,7 @@ class Model(BaseModel):
help_result_string = pydoc.render_doc(Model)
"""
)
warnings.simplefilter('error')
)
assert 'class Model' in module.help_result_string


Expand Down
13 changes: 4 additions & 9 deletions tests/test_root_model.py
@@ -1,5 +1,4 @@
import pickle
import warnings
from datetime import date, datetime
from typing import Any, Dict, List, Optional, Union

Expand Down Expand Up @@ -592,21 +591,17 @@ class Model(RootModel):


def test_help(create_module):
# since pydoc/help access all attributes to generate their documentation,
# this triggers the deprecation warnings.
with warnings.catch_warnings():
module = create_module(
# language=Python
"""
module = create_module(
# language=Python
"""
import pydoc
from pydantic import RootModel
help_result_string = pydoc.render_doc(RootModel)
"""
)
warnings.simplefilter('error')
)
assert 'class RootModel' in module.help_result_string


Expand Down

0 comments on commit f5fc834

Please sign in to comment.