MCPcopy Index your code
hub / github.com/python/cpython / test_yield_outside_function

Method test_yield_outside_function

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

Source from the content-addressed store, hash-verified

3047 self._check_error(source, "invalid syntax", lineno=3)
3048
3049 def test_yield_outside_function(self):
3050 self._check_error("if 0: yield", "outside function")
3051 self._check_error("if 0: yield\nelse: x=1", "outside function")
3052 self._check_error("if 1: pass\nelse: yield", "outside function")
3053 self._check_error("while 0: yield", "outside function")
3054 self._check_error("while 0: yield\nelse: x=1", "outside function")
3055 self._check_error("class C:\n if 0: yield", "outside function")
3056 self._check_error("class C:\n if 1: pass\n else: yield",
3057 "outside function")
3058 self._check_error("class C:\n while 0: yield", "outside function")
3059 self._check_error("class C:\n while 0: yield\n else: x = 1",
3060 "outside function")
3061
3062 def test_return_outside_function(self):
3063 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