(self)
| 231 | iprc(cell) |
| 232 | |
| 233 | def test_nonlocal(self): |
| 234 | # fails if outer scope is not a function scope or if var not defined |
| 235 | with self.assertRaises(SyntaxError): |
| 236 | iprc("nonlocal x") |
| 237 | iprc(""" |
| 238 | x = 1 |
| 239 | def f(): |
| 240 | nonlocal x |
| 241 | x = 10000 |
| 242 | yield x |
| 243 | """) |
| 244 | iprc(""" |
| 245 | def f(): |
| 246 | def g(): |
| 247 | nonlocal x |
| 248 | x = 10000 |
| 249 | yield x |
| 250 | """) |
| 251 | |
| 252 | # works if outer scope is a function scope and var exists |
| 253 | iprc(""" |
| 254 | def f(): |
| 255 | x = 20 |
| 256 | def g(): |
| 257 | nonlocal x |
| 258 | x = 10000 |
| 259 | yield x |
| 260 | """) |
| 261 | |
| 262 | |
| 263 | def test_execute(self): |
nothing calls this directly
no outgoing calls
no test coverage detected