Skip to content

Commit 942dacf

Browse files
authored
Merge pull request #58 from George-Ogden/side-effect
Allow Exceptions as `Mock.side_effect`
2 parents 9a2c13c + 6e91b29 commit 942dacf

File tree

10 files changed

+47
-22
lines changed

10 files changed

+47
-22
lines changed

.github/workflows/lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ on:
1010

1111
jobs:
1212
lint:
13-
uses: George-Ogden/actions/.github/workflows/lint.yaml@v3.2.0
13+
uses: George-Ogden/actions/.github/workflows/lint.yaml@v3.4.1

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ permissions:
1111

1212
jobs:
1313
release:
14-
uses: George-Ogden/actions/.github/workflows/python-release.yaml@v3.2.0
14+
uses: George-Ogden/actions/.github/workflows/python-release.yaml@v3.4.1
1515
with:
1616
validation-code: "import mypy.version; from mypy_pytest_plugin import plugin; plugin(mypy.version.__version__)"

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
matrix:
1515
shard: [0, 1, 2]
1616
total-shards: [3]
17-
uses: George-Ogden/actions/.github/workflows/python-test.yaml@v3.2.0
17+
uses: George-Ogden/actions/.github/workflows/python-test.yaml@v3.4.1
1818
with:
1919
python-versions: "['3.12', '3.13', '3.14']"
2020
timeout-minutes: 15

.gitignore

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ TODO
1111
*.patch
1212
nohup*
1313

14+
### VisualStudioCode ###
15+
.vscode/*
16+
17+
# Local History for Visual Studio Code
18+
.history
19+
.ionide
20+
21+
# Built Visual Studio Code Extensions
22+
*.vsix
23+
1424
### Python ###
1525
# Byte-compiled / optimized / DLL files
1626
__pycache__/
@@ -183,12 +193,5 @@ poetry.toml
183193
# LSP config files
184194
pyrightconfig.json
185195

186-
### VisualStudioCode ###
187-
.vscode/*
188-
189-
# Local History for Visual Studio Code
190-
.history
191-
.ionide
192-
193-
# Built Visual Studio Code Extensions
194-
*.vsix
196+
### Pre-Commit Prettier ###
197+
node_modules/

.mirror.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# DANGER: EDIT AT YOUR OWN RISK. Track this file in version control so that others can sync files correctly.
2-
- commit: 4519f0a82ab20cd50ec11c717ac75abcff7ea16c
2+
- commit: 26f0c34dacfaf7ad3d790b9b8a005daf242960b2
33
files:
44
- .github/python-release.yaml
55
- .github/python-test.yaml

.pre-commit-config.yaml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
default_stages: ["pre-commit"]
22
default_install_hook_types: ["pre-commit", "commit-msg"]
33

4+
ci:
5+
skip: [mirror-check]
6+
47
repos:
58
- repo: https://github.com/George-Ogden/mirror-rorrim/
6-
rev: v0.4.1
9+
rev: v0.4.4
710
hooks:
811
- id: mirror-check
912
fail_fast: true
@@ -17,33 +20,38 @@ repos:
1720
- id: requirements-txt-fixer
1821

1922
- repo: https://github.com/George-Ogden/linter/
20-
rev: v1.2.1
23+
rev: v1.2.2
2124
hooks:
2225
- id: lint
2326
args: [--fix]
2427

28+
- repo: https://github.com/koalaman/shellcheck-precommit
29+
rev: v0.11.0
30+
hooks:
31+
- id: shellcheck
32+
args: ["--severity=warning"]
33+
2534
- repo: https://github.com/astral-sh/ruff-pre-commit/
26-
rev: v0.14.10
35+
rev: v0.14.13
2736
hooks:
28-
- id: ruff-format
2937
- id: ruff-check
3038
args:
3139
- --fix
3240
exclude: ^test_samples/
41+
- id: ruff-format
3342

3443
- repo: https://github.com/pre-commit/mirrors-prettier/
3544
rev: v4.0.0-alpha.8
3645
hooks:
3746
- id: prettier
38-
additional_dependencies: [prettier]
3947

4048
- repo: https://github.com/rhysd/actionlint/
41-
rev: v1.7.9
49+
rev: v1.7.10
4250
hooks:
4351
- id: actionlint
4452

4553
- repo: https://github.com/George-Ogden/pre-commit-hooks/
46-
rev: v2.0.4
54+
rev: v2.1.0
4755
hooks:
4856
- id: check-merge-conflict
4957
- id: dbg-check

mypy_pytest_plugin_types/mock.pyi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ class CallableMixin[**P, R]:
9191
def __init__(
9292
self,
9393
spec: Any | None = None,
94-
side_effect: Callable[P, Any] | Iterable[R | Exception | type[Exception]] | None = None,
94+
side_effect: Callable[P, Any]
95+
| Iterable[R | Exception | type[Exception]]
96+
| Exception
97+
| type[Exception]
98+
| None = None,
9599
return_value: R = ...,
96100
wraps: Callable[P, R] | None = None,
97101
name: Any | None = None,

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
git+https://github.com/George-Ogden/mirror-rorrim; python_version >= "3.12"
33
git+https://github.com/George-Ogden/mypy-pytest; python_version >= "3.12"
44
git+https://github.com/George-Ogden/pytest-dbg
5+
git+https://github.com/George-Ogden/pytest-dbg; python_version >= "3.11"
56
inline-snapshot
67
pip
78
pre-commit

test_samples/patch_test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,12 @@ class TypeAliasTest:
100100

101101
mock.patch.object(TypeAliasTest, "f", lambda: None)
102102
mock.patch.object(TypeAliasTest, "f", lambda n: n)
103+
104+
value = None
105+
mock.patch("patch_test.value", mock.Mock(side_effect=None))
106+
mock.patch("patch_test.value", mock.Mock(side_effect=[None]))
107+
mock.patch("patch_test.value", mock.Mock(side_effect=[None, RuntimeError(), RuntimeError]))
108+
mock.patch("patch_test.value", mock.Mock(side_effect=[RuntimeError]))
109+
mock.patch("patch_test.value", mock.Mock(side_effect=[RuntimeError()]))
110+
mock.patch("patch_test.value", mock.Mock(side_effect=RuntimeError()))
111+
mock.patch("patch_test.value", mock.Mock(side_effect=RuntimeError))

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.1.2
1+
2.1.3

0 commit comments

Comments
 (0)