summaryrefslogtreecommitdiff
path: root/numpy/testing
diff options
context:
space:
mode:
authorMike Taves <mwtoews@gmail.com>2020-01-28 13:12:38 +1300
committerSebastian Berg <sebastian@sipsolutions.net>2020-01-27 16:12:38 -0800
commitf398a0df8a2105b2fdeaeab54505451169b0a869 (patch)
treefe041dbec09eb1a303f7b027cc98e7423476de3f /numpy/testing
parent6d889e7eca0f7ae6d640c380bd0b604e6530f049 (diff)
downloadnumpy-f398a0df8a2105b2fdeaeab54505451169b0a869.tar.gz
STY: use 'yield from <expr>' for simple cases (#15444)
This PR uses simple cases of PEP 380 to rewrite: for v in g: yield v into: yield from <expr>
Diffstat (limited to 'numpy/testing')
-rw-r--r--numpy/testing/_private/decorators.py3
-rw-r--r--numpy/testing/tests/test_decorators.py12
2 files changed, 5 insertions, 10 deletions
diff --git a/numpy/testing/_private/decorators.py b/numpy/testing/_private/decorators.py
index 661dcd91a..b4b6259a0 100644
--- a/numpy/testing/_private/decorators.py
+++ b/numpy/testing/_private/decorators.py
@@ -152,8 +152,7 @@ def skipif(skip_condition, msg=None):
if skip_val():
raise SkipTest(get_msg(f, msg))
else:
- for x in f(*args, **kwargs):
- yield x
+ yield from f(*args, **kwargs)
# Choose the right skipper to use when building the actual decorator.
if nose.util.isgenerator(f):
diff --git a/numpy/testing/tests/test_decorators.py b/numpy/testing/tests/test_decorators.py
index 77f8b66ba..b60d6dfbc 100644
--- a/numpy/testing/tests/test_decorators.py
+++ b/numpy/testing/tests/test_decorators.py
@@ -106,8 +106,7 @@ class TestNoseDecorators:
def test_skip_generators_hardcoded(self):
@dec.knownfailureif(True, "This test is known to fail")
def g1(x):
- for i in range(x):
- yield i
+ yield from range(x)
try:
for j in g1(10):
@@ -119,8 +118,7 @@ class TestNoseDecorators:
@dec.knownfailureif(False, "This test is NOT known to fail")
def g2(x):
- for i in range(x):
- yield i
+ yield from range(x)
raise self.DidntSkipException('FAIL')
try:
@@ -137,8 +135,7 @@ class TestNoseDecorators:
@dec.knownfailureif(skip_tester, "This test is known to fail")
def g1(x):
- for i in range(x):
- yield i
+ yield from range(x)
try:
skip_flag = 'skip me!'
@@ -151,8 +148,7 @@ class TestNoseDecorators:
@dec.knownfailureif(skip_tester, "This test is NOT known to fail")
def g2(x):
- for i in range(x):
- yield i
+ yield from range(x)
raise self.DidntSkipException('FAIL')
try: