diff --git a/test/test_datapipe.py b/test/test_datapipe.py index b5a38b2631f96..24e98f33b6980 100644 --- a/test/test_datapipe.py +++ b/test/test_datapipe.py @@ -1948,7 +1948,14 @@ def test_docstring(self): "shuffle", "zip", ]: - docstring = pydoc.render_doc(thing=getattr(input_dp, dp_funcname)) + if sys.version_info >= (3, 9): + docstring = pydoc.render_doc( + thing=getattr(input_dp, dp_funcname), forceload=True + ) + elif sys.version_info < (3, 9): + # pydoc works differently on Python 3.8, see + # https://docs.python.org/3/whatsnew/3.9.html#pydoc + docstring = getattr(input_dp, dp_funcname).__doc__ assert f"(functional name: ``{dp_funcname}``)" in docstring assert "Args:" in docstring assert "Example:" in docstring or "Examples:" in docstring