Skip to content

Commit

Permalink
Fix negative value test in test_helper
Browse files Browse the repository at this point in the history
`raises` was wrapping a function decorated with `for_unsigned_dtypes` and
`for_signed_dtypes`. In this scheme, if an error was raised in any of
the combinations of dtypes, the test would pass, which would be unintended.
  • Loading branch information
niboshi authored and takagi committed Jul 9, 2020
1 parent f446743 commit b8d0b62
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/cupy_tests/testing_tests/test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,18 +147,18 @@ def strange_kw_func(self, foo):

class TestIgnoreOfNegativeValueDifferenceOnCpuAndGpu(unittest.TestCase):

@helper.for_unsigned_dtypes('dtype1')
@helper.for_signed_dtypes('dtype2')
@helper.numpy_cupy_allclose()
def correct_failure(self, xp, dtype1, dtype2):
def correct_failure(self, dtype1, dtype2, xp):
if xp == numpy:
return xp.array(-1, dtype=numpy.float32)
else:
return xp.array(-2, dtype=numpy.float32)

def test_correct_failure(self):
@helper.for_unsigned_dtypes('dtype1')
@helper.for_signed_dtypes('dtype2')
def test_correct_failure(self, dtype1, dtype2):
with pytest.raises(AssertionError):
self.correct_failure()
self.correct_failure(dtype1, dtype2)

@helper.for_unsigned_dtypes('dtype1')
@helper.for_signed_dtypes('dtype2')
Expand Down

0 comments on commit b8d0b62

Please sign in to comment.