MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_yield_outside_function

Method test_yield_outside_function

Lib/test/test_syntax.py:2354–2365  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2352 self._check_error(source, "parameter and nonlocal", lineno=3)
2353
2354 def test_yield_outside_function(self):
2355 self._check_error("if 0: yield", "outside function")
2356 self._check_error("if 0: yield\nelse: x=1", "outside function")
2357 self._check_error("if 1: pass\nelse: yield", "outside function")
2358 self._check_error("while 0: yield", "outside function")
2359 self._check_error("while 0: yield\nelse: x=1", "outside function")
2360 self._check_error("class C:\n if 0: yield", "outside function")
2361 self._check_error("class C:\n if 1: pass\n else: yield",
2362 "outside function")
2363 self._check_error("class C:\n while 0: yield", "outside function")
2364 self._check_error("class C:\n while 0: yield\n else: x = 1",
2365 "outside function")
2366
2367 def test_return_outside_function(self):
2368 self._check_error("if 0: return", "outside function")

Callers

nothing calls this directly

Calls 1

_check_errorMethod · 0.95

Tested by

no test coverage detected