Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Prev Previous commit
Improved tests
  • Loading branch information
Xiaokang2022 committed Oct 19, 2024
commit 95ac2c6febeef52bf6c7eb5fef81be453d8d1587
14 changes: 10 additions & 4 deletions Lib/test/test_inspect/test_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,6 @@ def test_excluding_predicates(self):
self.istest(inspect.ismethod, 'git.argue')
self.istest(inspect.ismethod, 'mod.custom_method')
self.istest(inspect.ismodule, 'mod')
self.istest(inspect.ispackage, 'asyncio')
self.istest(inspect.ispackage, 'importlib')
self.assertFalse(inspect.ispackage(mod))
self.assertFalse(inspect.ispackage(':)'))
self.istest(inspect.ismethoddescriptor, 'int.__add__')
self.istest(inspect.isdatadescriptor, 'collections.defaultdict.default_factory')
self.istest(inspect.isgenerator, '(x for x in range(2))')
Expand All @@ -208,7 +204,17 @@ def test_excluding_predicates(self):
self.assertFalse(inspect.ismethodwrapper(int))
self.assertFalse(inspect.ismethodwrapper(type("AnyClass", (), {})))

def test_ispackage(self):
self.istest(inspect.ispackage, 'asyncio')
self.istest(inspect.ispackage, 'importlib')
self.assertFalse(inspect.ispackage(inspect))
self.assertFalse(inspect.ispackage(mod))
self.assertFalse(inspect.ispackage(':)'))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This last test genuinely made me laugh :)


class FakePackage:
__path__ = None

self.assertFalse(inspect.ispackage(FakePackage()))

def test_iscoroutine(self):
async_gen_coro = async_generator_function_example(1)
Expand Down