Skip to content

Commit ce5ec55

Browse files
committed
Test Python thread safety with pytest-run-parallel
1 parent 9c6f3e1 commit ce5ec55

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

.github/workflows/integration.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,27 @@ jobs:
2525
strategy:
2626
max-parallel: 15
2727
matrix:
28-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14', '3.14t', 'pypy-3.8', 'pypy-3.9', 'pypy-3.10', 'pypy-3.11']
28+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14', '3.14t', 'pypy-3.9', 'pypy-3.10', 'pypy-3.11']
2929
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
3030
fail-fast: false
3131
env:
3232
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
3333
name: Python ${{ matrix.python-version }} ${{matrix.os}}
3434
steps:
35-
- uses: actions/checkout@v4
35+
- uses: actions/checkout@v5
3636
with:
3737
submodules: recursive
38-
- uses: actions/setup-python@v5
38+
- uses: actions/setup-python@v6
3939
with:
4040
python-version: ${{ matrix.python-version }}
4141
cache: 'pip'
4242
cache-dependency-path: dev_requirements.txt
4343
- name: run tests
4444
run: |
45-
pip install -U pip setuptools wheel
45+
pip install --upgrade pip setuptools wheel
4646
pip install -r dev_requirements.txt
4747
python setup.py build_ext --inplace
48-
python -m pytest
48+
python -m pytest --iterations=8 --parallel-threads=auto
4949
- name: build and install the wheel
5050
run: |
5151
python setup.py bdist_wheel

dev_requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ black==24.3.0
22
flake8==4.0.1
33
isort==5.10.1
44
pytest>=7.0.0
5+
pytest-run-parallel>=0.7.1
56
setuptools
67
vulture>=2.3.0
78
wheel>=0.30.0

tests/test_reader.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ def test_dict(reader):
174174
assert {b"radius": 4.5, b"diameter": 9} == reader.gets()
175175

176176

177+
@pytest.mark.iterations(1)
178+
@pytest.mark.thread_unsafe
177179
def test_set_with_nested_dict(reader):
178180
reader.feed(b"~2\r\n+tangerine\r\n%1\r\n+a\r\n:1\r\n")
179181
if reader.convertSetsToLists:
@@ -196,6 +198,8 @@ def test_map_inside_list(reader):
196198
assert [{b"a": 1}] == reader.gets()
197199

198200

201+
@pytest.mark.iterations(1)
202+
@pytest.mark.thread_unsafe
199203
def test_map_inside_set(reader):
200204
reader.feed(b"~1\r\n%1\r\n+a\r\n:1\r\n")
201205
if reader.convertSetsToLists:
@@ -206,6 +210,8 @@ def test_map_inside_set(reader):
206210
reader.gets()
207211

208212

213+
@pytest.mark.iterations(1)
214+
@pytest.mark.thread_unsafe
209215
def test_set_as_map_key(reader):
210216
reader.feed(b"%1\r\n~1\r\n:1\r\n:2\r\n")
211217
with pytest.raises(TypeError):
@@ -388,6 +394,8 @@ def test_feed_bytearray(reader):
388394
assert b"ok" == reader.gets()
389395

390396

397+
@pytest.mark.iterations(1)
398+
@pytest.mark.thread_unsafe
391399
def test_maxbuf(reader):
392400
defaultmaxbuf = reader.getmaxbuf()
393401
reader.setmaxbuf(0)
@@ -400,6 +408,8 @@ def test_maxbuf(reader):
400408
reader.setmaxbuf(-4)
401409

402410

411+
@pytest.mark.iterations(1)
412+
@pytest.mark.thread_unsafe
403413
def test_len(reader):
404414
assert reader.len() == 0
405415
data = b"+ok\r\n"
@@ -416,6 +426,8 @@ def test_len(reader):
416426
assert reader.len() == 5
417427

418428

429+
@pytest.mark.iterations(1)
430+
@pytest.mark.thread_unsafe
419431
def test_reader_has_data(reader):
420432
assert reader.has_data() is False
421433
data = b"+ok\r\n"

0 commit comments

Comments
 (0)