Commit 192ba37
authored
Fix function attribute tests: __defaults__ del, __code__ free vars ch… (RustPython#7749)
* Fix function attribute tests: __defaults__ del, __code__ free vars check, bound method dir()
- Support `del func.__defaults__` and `del func.__kwdefaults__` by changing
setter signatures to `PySetterValue<Option<...>>` so Delete is treated as
setting the value to None (matching CPython behaviour)
- Validate free-variable count when assigning to `func.__code__`: raise
ValueError when the new code object's freevars count doesn't match the
existing closure size
- Add `__dir__` to `PyBoundMethod` that delegates to the underlying
function's dir(), so attributes set on the function show up in
`dir(bound_method)`
- Remove `@unittest.expectedFailure` from the four tests that now pass:
test_blank_func_defaults, test_func_default_args, test___code__,
test_dir_includes_correct_attrs
* Remove expectedFailure markers for now-passing tests1 parent d25195e commit 192ba37
3 files changed
Lines changed: 57 additions & 12 deletions
File tree
- Lib/test
- test_unittest/testmock
- crates/vm/src/builtins
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
54 | 53 | | |
55 | 54 | | |
56 | 55 | | |
| |||
238 | 237 | | |
239 | 238 | | |
240 | 239 | | |
241 | | - | |
242 | 240 | | |
243 | 241 | | |
244 | 242 | | |
| |||
269 | 267 | | |
270 | 268 | | |
271 | 269 | | |
272 | | - | |
273 | 270 | | |
274 | 271 | | |
275 | 272 | | |
276 | 273 | | |
277 | 274 | | |
278 | | - | |
279 | 275 | | |
280 | 276 | | |
281 | 277 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2012 | 2012 | | |
2013 | 2013 | | |
2014 | 2014 | | |
2015 | | - | |
2016 | 2015 | | |
2017 | 2016 | | |
2018 | 2017 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
| 5 | + | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
788 | 788 | | |
789 | 789 | | |
790 | 790 | | |
791 | | - | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
792 | 802 | | |
793 | 803 | | |
794 | 804 | | |
| |||
797 | 807 | | |
798 | 808 | | |
799 | 809 | | |
| 810 | + | |
800 | 811 | | |
801 | 812 | | |
802 | 813 | | |
803 | 814 | | |
804 | 815 | | |
805 | 816 | | |
806 | 817 | | |
807 | | - | |
808 | | - | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
809 | 823 | | |
810 | 824 | | |
811 | 825 | | |
| |||
814 | 828 | | |
815 | 829 | | |
816 | 830 | | |
817 | | - | |
818 | | - | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
819 | 836 | | |
820 | 837 | | |
821 | 838 | | |
| |||
1308 | 1325 | | |
1309 | 1326 | | |
1310 | 1327 | | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
1311 | 1361 | | |
1312 | 1362 | | |
1313 | 1363 | | |
| |||
0 commit comments