Commit 4e69397
committed
Issue #119600: mock: do not access attributes of original when new_callable is set
In order to patch flask.g e.g. as in #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.1 parent c7a5e1e commit 4e69397
1 file changed
Lines changed: 7 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1508 | 1508 | | |
1509 | 1509 | | |
1510 | 1510 | | |
1511 | | - | |
1512 | | - | |
1513 | | - | |
1514 | | - | |
1515 | | - | |
| 1511 | + | |
| 1512 | + | |
1516 | 1513 | | |
1517 | 1514 | | |
| 1515 | + | |
| 1516 | + | |
1518 | 1517 | | |
1519 | 1518 | | |
1520 | 1519 | | |
| |||
1527 | 1526 | | |
1528 | 1527 | | |
1529 | 1528 | | |
| 1529 | + | |
| 1530 | + | |
1530 | 1531 | | |
| 1532 | + | |
1531 | 1533 | | |
1532 | 1534 | | |
1533 | 1535 | | |
| |||
0 commit comments