diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2025-05-12 16:10:56 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-12 22:10:56 +0000 |
commit | 8cf4947b0f2d37f7ffeca136ac4f99cb4cb70e5c (patch) | |
tree | 556a2a34633f18e7271467d73854ad344831f33d /Lib/test/test_crossinterp.py | |
parent | 121ed71f4e395948d313249b2ad33e1e21581f8a (diff) | |
download | cpython-8cf4947b0f2d37f7ffeca136ac4f99cb4cb70e5c.tar.gz cpython-8cf4947b0f2d37f7ffeca136ac4f99cb4cb70e5c.zip |
gh-132775: Add _PyFunction_GetXIData() (gh-133481)
Diffstat (limited to 'Lib/test/test_crossinterp.py')
-rw-r--r-- | Lib/test/test_crossinterp.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Lib/test/test_crossinterp.py b/Lib/test/test_crossinterp.py index b366a29645e..cddacbc9970 100644 --- a/Lib/test/test_crossinterp.py +++ b/Lib/test/test_crossinterp.py @@ -758,6 +758,40 @@ class CodeTests(_GetXIDataTests): ]) +class ShareableFuncTests(_GetXIDataTests): + + MODE = 'func' + + def test_stateless(self): + self.assert_roundtrip_not_equal([ + *defs.STATELESS_FUNCTIONS, + # Generators can be stateless too. + *defs.FUNCTION_LIKE, + ]) + + def test_not_stateless(self): + self.assert_not_shareable([ + *(f for f in defs.FUNCTIONS + if f not in defs.STATELESS_FUNCTIONS), + ]) + + def test_other_objects(self): + self.assert_not_shareable([ + None, + True, + False, + Ellipsis, + NotImplemented, + 9999, + 'spam', + b'spam', + (), + [], + {}, + object(), + ]) + + class PureShareableScriptTests(_GetXIDataTests): MODE = 'script-pure' |