def test_Integer(self): """Test IntegerOption.""" option = bot.IntegerOption(maximum=5, prefix='r') self.assertEqual(option.format('2'), 'r<number> [1-5]') self.assertEqual(option.format('r2'), 'r<number> [1-[2]-5]') self.assertEqual(message('?', [option], None), '? (r<number> [1-5])') self.assertEqual(message('?', [option], 'r3'), '? (r<number> [1-[3]-5])') self.assertRaises(AttributeError, option.test, 1) self.assertFalse(option.test('0')) self.assertFalse(option.test('r0')) self.assertFalse(option.test('r6')) self.assertIsNone(option.handled('r6')) for i in range(1, 6): self.assertTrue(option.test('r%d' % i)) self.assertEqual(option.handled('r%d' % i), option) self.assertEqual(option.result('r%d' % i), ('r', i))
def test_Integer(self): """Test IntegerOption.""" option = bot.IntegerOption(maximum=5, prefix='r') self.assertTrue(option.stop) self.assertEqual(option.format('2'), 'r<number> [1-5]') self.assertEqual(option.format('r2'), 'r<number> [1-[2]-5]') self.assertEqual(option.format(default='r2'), 'r<number> [1-[2]-5]') self.assertEqual(option.format(), 'r<number> [1-5]') self.assertEqual(message('?', [option], None), '? (r<number> [1-5])') self.assertEqual(message('?', [option], 'r3'), '? (r<number> [1-[3]-5])') with self.assertRaisesRegex(AttributeError, self.TEST_RE): option.test(1) self.assertFalse(option.test('0')) self.assertFalse(option.test('r0')) self.assertFalse(option.test('r6')) self.assertIsNone(option.handled('r6')) for i in range(1, 6): self.assertTrue(option.test('r{}'.format(i))) self.assertEqual(option.handled('r{}'.format(i)), option) self.assertEqual(option.result('r{}'.format(i)), ('r', i))