@@ -126,7 +126,8 @@ class CliTest(unittest.TestCase):
126
126
def setUp (self ):
127
127
pdoc .reset ()
128
128
129
- @unittest .skipIf (sys .version_info < (3 , 7 ), 'pdoc._formatannotation fails on Py3.6' )
129
+ @unittest .skipIf (sys .version_info < (3 , 10 ),
130
+ 'HACK: _formatannotation() changed return value in Py3.10' )
130
131
def test_project_doctests (self ):
131
132
doctests = doctest .testmod (pdoc )
132
133
assert not doctests .failed and doctests .attempted , doctests
@@ -185,8 +186,12 @@ def test_html(self):
185
186
'<object ' ,
186
187
' class="ident">_private' ,
187
188
' class="ident">_Private' ,
188
- 'non_callable_routine' ,
189
189
]
190
+ if sys .version_info >= (3 , 10 ):
191
+ include_patterns .append ('non_callable_routine' )
192
+ else :
193
+ exclude_patterns .append ('non_callable_routine' )
194
+
190
195
package_files = {
191
196
'' : self .PUBLIC_FILES ,
192
197
'.subpkg2' : [f for f in self .PUBLIC_FILES
@@ -356,8 +361,11 @@ def test_text(self):
356
361
'_Private' ,
357
362
'subprocess' ,
358
363
'Hidden' ,
359
- 'non_callable_routine' ,
360
364
]
365
+ if sys .version_info >= (3 , 10 ):
366
+ include_patterns .append ('non_callable_routine' )
367
+ else :
368
+ exclude_patterns .append ('non_callable_routine' )
361
369
362
370
with self .subTest (package = EXAMPLE_MODULE ):
363
371
with redirect_streams () as (stdout , _ ):
@@ -543,8 +551,9 @@ class C:
543
551
self .assertEqual (doc .doc ['vars_dont' ].docstring , '' )
544
552
self .assertIn ('integer' , doc .doc ['but_clss_have_doc' ].docstring )
545
553
554
+ @unittest .skipIf (sys .version_info >= (3 , 10 ), 'No builtin module "parser" in Py3.10' )
546
555
def test_builtin_methoddescriptors (self ):
547
- import parser
556
+ import parser # TODO: replace with another public binary builtin
548
557
with self .assertWarns (UserWarning ):
549
558
c = pdoc .Class ('STType' , pdoc .Module (parser ), parser .STType )
550
559
self .assertIsInstance (c .doc ['compile' ], pdoc .Function )
@@ -906,9 +915,13 @@ def bug130_str_annotation(a: "str"):
906
915
def bug253_newtype_annotation (a : CustomType ):
907
916
return
908
917
918
+ expected = CustomType .__name__
919
+ if sys .version_info > (3 , 10 ):
920
+ expected = f'{ __name__ } .{ CustomType .__name__ } '
921
+
909
922
self .assertEqual (
910
923
pdoc .Function ('bug253' , mod , bug253_newtype_annotation ).params (annotate = True ),
911
- ['a:\N{NBSP} CustomType ' ])
924
+ [f 'a:\N{NBSP} { expected } ' ])
912
925
913
926
# typing.Callable bug
914
927
def f (a : typing .Callable ):
0 commit comments