def test_length__range(self): result = __unit__.random(self.LENGTH_RANGE) self.assertGreaterEqual(len(result), self.MIN_LENGTH) self.assertLessEqual(len(result), self.MAX_LENGTH)
def test_length__invalid_tuple(self): with self.assertRaises(TypeError): __unit__.random((1, 2, 3))
def test_length__constant(self): result = __unit__.random(self.LENGTH) self.assertEquals(self.LENGTH, len(result))
def test_length__some_object(self): with self.assertRaises(TypeError): __unit__.random(object())
def test_length__negative(self): with self.assertRaises(ValueError) as r: __unit__.random(self.NEGATIVE_LENGTH) self.assertIn(str(self.NEGATIVE_LENGTH), str(r.exception))
def test_chars__empty_string(self): with self.assertRaises(ValueError) as r: __unit__.random(self.LENGTH, '') self.assertIn("empty", str(r.exception))
def test_chars__non_string_iterable(self): with self.assertRaises(TypeError): __unit__.random(self.LENGTH, ('a', 'b'))
def test_chars__some_object(self): with self.assertRaises(TypeError): __unit__.random(self.LENGTH, object())
def test_chars__string(self): result = __unit__.random(self.LENGTH, self.CHARSET) for char in result: self.assertIn(char, self.CHARSET)
def test_length__none(self): with self.assertRaises(TypeError): __unit__.random(None)