Create a mixin for invalid outs tests
@@ -206,10 +206,37 @@ class TestBeta(GeneratorTestCase):
a=self.a, b=self.b, size=2000, dtype=dtype)
+class InvalidOutsMixin:
+
+ def invalid_dtype_out(self, **kwargs):
+ out = cupy.zeros((3, 2), dtype=cupy.float32)
+ with pytest.raises(TypeError):
+ self.generate(size=(3, 2), out=out, **kwargs)
+
+ def invalid_contiguity(self, **kwargs):
+ out = cupy.zeros((4, 6), dtype=cupy.float64)[0:3:, 0:2:]
+ with pytest.raises(ValueError):
+ self.generate(size=(3, 2), out=out, **kwargs)
+
+ def invalid_shape(self, **kwargs):
+ out = cupy.zeros((3, 3), dtype=cupy.float64)
+ with pytest.raises(ValueError):
+ self.generate(size=(3, 2), out=out, **kwargs)
+
+ def test_invalid_dtype_out(self):
+ self.invalid_dtype_out()
+
+ def test_invalid_contiguity(self):
+ self.invalid_contiguity()
+
+ def test_invalid_shape(self):
+ self.invalid_shape()
+
+
@testing.with_requires('numpy>=1.17.0')
@testing.gpu
@testing.fix_random()
-class TestStandardExponential(GeneratorTestCase):
+class TestStandardExponential(GeneratorTestCase, InvalidOutsMixin):
target_method = 'standard_exponential'
@@ -227,21 +254,6 @@ class TestStandardExponential(GeneratorTestCase):
def test_standard_exponential_ks(self, dtype):
self.check_ks(0.05)(size=2000, dtype=dtype)
- def test_standard_exponential_invalid_dtype_out(self):
- out = cupy.zeros((3, 2), dtype=cupy.float32)
- with pytest.raises(TypeError):
- self.generate(size=(3, 2), out=out)
-
- def test_standard_exponential_invalid_contiguity(self):
- out = cupy.zeros((4, 6), dtype=cupy.float64)[0:3:, 0:2:]
- with pytest.raises(ValueError):
- self.generate(size=(3, 2), out=out)
-
- def test_standard_exponential_invalid_dtype_shape(self):
- out = cupy.zeros((3, 3), dtype=cupy.float64)
- with pytest.raises(ValueError):
- self.generate(size=(3, 2), out=out)
-
@testing.with_requires('numpy>=1.17.0')
@testing.gpu
