Skip to content

Commit 47e9925

Browse files
committed
Add a test that we're not enabling the GIL.
1 parent 0778d50 commit 47e9925

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ jobs:
107107
run: |
108108
sphinx-build -b doctest -d docs/_build/doctrees2 docs docs/_build/doctest2
109109
- name: Lint
110-
if: matrix.python-version == '3.12' && startsWith(runner.os, 'Linux')
110+
if: matrix.python-version == '3.14' && startsWith(runner.os, 'Linux')
111111
# We only need to do this on one version.
112112
# We do this here rather than a separate job to avoid the compilation overhead.
113113
run: |

src/greenlet/tests/test_greenlet.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,8 +1134,9 @@ def test_deeper_cycle(self):
11341134

11351135
class TestRepr(TestCase):
11361136

1137-
def assertEndsWith(self, got, suffix):
1138-
self.assertTrue(got.endswith(suffix), (got, suffix))
1137+
if not hasattr(TestCase, 'assertEndsWith'): # Added in 3.14
1138+
def assertEndsWith(self, s, suffix, msg=None):
1139+
self.assertTrue(s.endswith(suffix), (s, suffix, msg))
11391140

11401141
def test_main_while_running(self):
11411142
r = repr(greenlet.getcurrent())
@@ -1349,5 +1350,16 @@ def test_reentrant_switch_run_callable_has_del(self):
13491350
output
13501351
)
13511352

1353+
class TestModule(TestCase):
1354+
1355+
@unittest.skipUnless(hasattr(sys, '_is_gil_enabled'),
1356+
"Needs 3.13 and above for sys._is_gil_enabled")
1357+
def test_no_gil_on_free_threaded(self):
1358+
1359+
if RUNNING_ON_FREETHREAD_BUILD:
1360+
self.assertFalse(sys._is_gil_enabled())
1361+
else:
1362+
self.assertTrue(sys._is_gil_enabled())
1363+
13521364
if __name__ == '__main__':
13531365
unittest.main()

0 commit comments

Comments
 (0)