Commit edeabd6
committed
tests: Fix test_module for Python 3.14
Python 3.14 changed argparse to lazily import _colorize during
ArgumentParser.__init__, triggering a chain of imports
(_colorize -> dataclasses -> inspect -> tokenize) that ends with
`from builtins import open`. The class-level mock.patch.dict on
sys.modules with clear=True removed builtins from sys.modules,
causing this import to fail with ImportError.
Narrow the mock scope to wrap only the take_action call rather
than the entire test class, so get_parser/argparse initialization
runs with an unpatched sys.modules while take_action still
iterates the controlled set of fake modules.
Assisted-By: claude-code
Change-Id: I0e1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a
Signed-off-by: Jay Faulkner <jay@jvf.cc>1 parent 437914a commit edeabd6
1 file changed
Lines changed: 12 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | 131 | | |
137 | 132 | | |
138 | 133 | | |
| |||
150 | 145 | | |
151 | 146 | | |
152 | 147 | | |
153 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
180 | | - | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
181 | 186 | | |
182 | 187 | | |
183 | 188 | | |
| |||
0 commit comments