Commit fa291a3
gh-119600: mock: do not access attributes of original when new_callable is set (GH-119601)
In order to patch flask.g e.g. as in GH-84982, that
proxies getattr must not be invoked. For that,
mock must not try to read from the original
object. In some cases that is unavoidable, e.g.
when doing autospec. However, patch("flask.g",
new_callable=MagicMock) should be entirely safe.
(cherry picked from commit 422c4fc)
Co-authored-by: Robert Collins <robert.collins@cognite.com>
1 parent a9f2daf commit fa291a3
File tree
4 files changed
+29
-5
lines changed- Lib
- test/test_unittest/testmock
- unittest
- Misc/NEWS.d/next/Library
4 files changed
+29
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2045 | 2045 | | |
2046 | 2046 | | |
2047 | 2047 | | |
| 2048 | + | |
| 2049 | + | |
| 2050 | + | |
| 2051 | + | |
| 2052 | + | |
| 2053 | + | |
| 2054 | + | |
2048 | 2055 | | |
2049 | 2056 | | |
2050 | 2057 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1478 | 1478 | | |
1479 | 1479 | | |
1480 | 1480 | | |
1481 | | - | |
1482 | | - | |
1483 | | - | |
1484 | | - | |
1485 | | - | |
| 1481 | + | |
| 1482 | + | |
1486 | 1483 | | |
1487 | 1484 | | |
| 1485 | + | |
| 1486 | + | |
1488 | 1487 | | |
1489 | 1488 | | |
1490 | 1489 | | |
| |||
1497 | 1496 | | |
1498 | 1497 | | |
1499 | 1498 | | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
1500 | 1503 | | |
| 1504 | + | |
1501 | 1505 | | |
1502 | 1506 | | |
1503 | 1507 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
0 commit comments