Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Skip test_capsule_type when no _types
  • Loading branch information
youknowone committed Feb 19, 2026
commit 9fcb7a441bc03f3fe7c642777d15e66d08082812
2 changes: 1 addition & 1 deletion Lib/test/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ def test_traceback_and_frame_types(self):
self.assertIsInstance(exc.__traceback__, types.TracebackType)
self.assertIsInstance(exc.__traceback__.tb_frame, types.FrameType)

@unittest.skipUnless(_datetime, "requires _datetime module")
@unittest.skipUnless(_types and _datetime, "requires _datetime module")
def test_capsule_type(self):
self.assertIsInstance(_datetime.datetime_CAPI, types.CapsuleType)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

_datetime is only used in this test, so we can import it locally. We can use test.support.import_module() to skip the test.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can use test.support.get_attribute(types, 'CapsuleType') to skip the test if CapsuleType is not available.


Expand Down
Loading