Skip to content

Commit 21215b0

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

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ def test_dict(reader):
174174
assert {b"radius": 4.5, b"diameter": 9} == reader.gets()
175175

176176

177+
@pytest.mark.thread_unsafe
177178
def test_set_with_nested_dict(reader):
178179
reader.feed(b"~2\r\n+tangerine\r\n%1\r\n+a\r\n:1\r\n")
179180
if reader.convertSetsToLists:
@@ -196,6 +197,7 @@ def test_map_inside_list(reader):
196197
assert [{b"a": 1}] == reader.gets()
197198

198199

200+
@pytest.mark.thread_unsafe
199201
def test_map_inside_set(reader):
200202
reader.feed(b"~1\r\n%1\r\n+a\r\n:1\r\n")
201203
if reader.convertSetsToLists:
@@ -206,6 +208,7 @@ def test_map_inside_set(reader):
206208
reader.gets()
207209

208210

211+
@pytest.mark.thread_unsafe
209212
def test_set_as_map_key(reader):
210213
reader.feed(b"%1\r\n~1\r\n:1\r\n:2\r\n")
211214
with pytest.raises(TypeError):
@@ -400,6 +403,7 @@ def test_maxbuf(reader):
400403
reader.setmaxbuf(-4)
401404

402405

406+
@pytest.mark.thread_unsafe
403407
def test_len(reader):
404408
assert reader.len() == 0
405409
data = b"+ok\r\n"

0 commit comments

Comments
 (0)