Commit 38be2c4
fix(tests): fix Python 3.10-only mock.patch AttributeError in fknm fallback tests (#539)
* fix(tests): fix Python 3.10-only mock.patch AttributeError in fknm fallback tests
roboticstoolbox/robot/ETS.py defines a class also called ETS, and
robot/__init__.py's `from ...ETS import ETS` rebinds the "ETS"
attribute on the roboticstoolbox.robot package to the class, shadowing
the submodule of the same name. Python 3.10's unittest.mock resolves
dotted-string patch targets via plain getattr (falling back to import
only on AttributeError), so patch("...ETS.ETS_fkine", ...) resolved
"ETS" to the shadowing class and failed with AttributeError; 3.11+
uses pkgutil.resolve_name and isn't fooled by the same shadowing. This
is why it only ever showed up on Python 3.10 in CI.
Not a real code bug - the actual fknm/facade fallback machinery was
always fine, only the test's patch target resolution was broken on
3.10. Fixed by looking up the real module via sys.modules directly
(the only lookup with no getattr involved) and patching against that
with patch.object() instead of a dotted string.
Rehearsed: all 41 tests in test_fknm_fallback.py pass under both
Python 3.10 and 3.13.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* docs(tech-debt): note the Python 3.10 mock workaround for future removal
Cross-references the fknm fallback test fix in this same branch.
Python 3.10 reaches EOL October 2026 — flag this specific workaround
for removal (and a general 3.10-specific-code sweep) at that point.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>1 parent fc51bc2 commit 38be2c4
2 files changed
Lines changed: 60 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
647 | 647 | | |
648 | 648 | | |
649 | 649 | | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
26 | 45 | | |
27 | 46 | | |
28 | 47 | | |
| |||
57 | 76 | | |
58 | 77 | | |
59 | 78 | | |
60 | | - | |
| 79 | + | |
61 | 80 | | |
62 | 81 | | |
63 | 82 | | |
| |||
69 | 88 | | |
70 | 89 | | |
71 | 90 | | |
72 | | - | |
| 91 | + | |
73 | 92 | | |
74 | 93 | | |
75 | 94 | | |
| |||
81 | 100 | | |
82 | 101 | | |
83 | 102 | | |
84 | | - | |
| 103 | + | |
85 | 104 | | |
86 | 105 | | |
87 | 106 | | |
| |||
101 | 120 | | |
102 | 121 | | |
103 | 122 | | |
104 | | - | |
| 123 | + | |
105 | 124 | | |
106 | 125 | | |
107 | 126 | | |
| |||
121 | 140 | | |
122 | 141 | | |
123 | 142 | | |
124 | | - | |
| 143 | + | |
125 | 144 | | |
126 | 145 | | |
127 | 146 | | |
| |||
0 commit comments