示例#1
0
 def test_many(self):
     for i in range(100):
         lbproc = _LBProc(i)
         with mock.patch('warnings.warn') as warn:
             flag = lbproc.flag2
         self.assertEqual(warn.call_count, 1)
         self.assertEqual(flag, bool(i & 2))
示例#2
0
 def test_equal_int(self):
     self.assertTrue(_LBProc(17).__eq__(17))
示例#3
0
 def test_invalid_str(self):
     with self.assertRaisesRegexp(ValueError, 'invalid literal for int'):
         _LBProc('asdf')
示例#4
0
 def test_double_digit_slice(self):
     lbproc = _LBProc(1234)
     with mock.patch('warnings.warn') as warn:
         lbproc[1:3] = 65
     self.assertEqual(warn.call_count, 4)
     self.assertEqual(lbproc, 1654)
示例#5
0
 def test_str(self):
     _LBProc('245')
示例#6
0
 def test_invalid(self):
     lbproc = _LBProc(1234)
     with mock.patch('warnings.warn') as warn:
         with self.assertRaises(ValueError):
             lbproc[1] = 81
     self.assertEqual(warn.call_count, 1)
示例#7
0
 def test_out_of_bounds_scalar(self):
     lbproc = _LBProc(1234)
     with mock.patch('warnings.warn') as warn:
         lbproc[9] = 4
     self.assertEqual(warn.call_count, 1)
     self.assertEqual(lbproc, 4000001234)
示例#8
0
 def test_not_equal_int(self):
     self.assertTrue(_LBProc(10).__ne__(15))
示例#9
0
 def test(self):
     lbproc = _LBProc(12)
     lbproc &= 8
     self.assertEqual(int(lbproc), 8)
示例#10
0
 def test_equal_int(self):
     self.assertFalse(_LBProc(8).__ne__(8))
示例#11
0
 def test_not_equal(self):
     self.assertTrue(_LBProc(9).__ne__(_LBProc(14)))
示例#12
0
 def test_equal(self):
     self.assertFalse(_LBProc(7).__ne__(_LBProc(7)))
示例#13
0
 def test_not_equal_int(self):
     self.assertFalse(_LBProc(17).__eq__(16))
示例#14
0
 def test_not_equal(self):
     self.assertFalse(_LBProc(17).__eq__(_LBProc(18)))
示例#15
0
 def test_out_of_bounds_slice(self):
     lbproc = _LBProc(1234)
     with mock.patch('warnings.warn') as warn:
         digit = lbproc[10:]
     self.assertEqual(warn.call_count, 1)
     self.assertEqual(digit, 0)
示例#16
0
 def test(self):
     lbproc = _LBProc(12)
     lbproc |= 1
     self.assertEqual(int(lbproc), 13)
示例#17
0
 def test_ok(self):
     lbproc = _LBProc(1234)
     with mock.patch('warnings.warn') as warn:
         lbproc[1] = 9
     self.assertEqual(warn.call_count, 1)
     self.assertEqual(int(lbproc), 1294)
示例#18
0
 def test(self):
     lbproc = _LBProc(26)
     with mock.patch('warnings.warn') as warn:
         flags = lbproc.flags
     self.assertEqual(warn.call_count, 1)
     self.assertEqual(flags, (2, 8, 16))
示例#19
0
 def test_int(self):
     _LBProc(42)
示例#20
0
 def test(self):
     lbproc = _LBProc(8641)
     self.assertEqual(repr(lbproc), '_LBProc(8641)')
示例#21
0
 def test_single_digit_slice(self):
     lbproc = _LBProc(1234)
     with mock.patch('warnings.warn') as warn:
         lbproc[1:2] = 6
     self.assertEqual(warn.call_count, 3)
     self.assertEqual(lbproc, 1264)
示例#22
0
 def test(self):
     lbproc = _LBProc(8641)
     self.assertEqual(str(lbproc), '8641')
示例#23
0
 def test_out_of_bounds_slice(self):
     lbproc = _LBProc(1234)
     with mock.patch('warnings.warn') as warn:
         lbproc[6:] = 49
     self.assertEqual(warn.call_count, 4)
     self.assertEqual(lbproc, 49001234)
示例#24
0
 def test_positive(self):
     lbproc = _LBProc(24)
     with mock.patch('warnings.warn') as warn:
         length = len(lbproc)
     self.assertEqual(warn.call_count, 1)
     self.assertEqual(length, 2)
示例#25
0
 def test_negative(self):
     msg = 'Negative numbers not supported with splittable integers object'
     with self.assertRaisesRegexp(ValueError, msg):
         _LBProc(-1)
     with self.assertRaisesRegexp(ValueError, msg):
         _LBProc('-1')
示例#26
0
 def test_normal_scalar(self):
     lbproc = _LBProc(1234)
     with mock.patch('warnings.warn') as warn:
         digit = lbproc[1]
     self.assertEqual(warn.call_count, 1)
     self.assertEqual(digit, 3)
示例#27
0
 def test_false(self):
     lbproc = _LBProc(1)
     with mock.patch('warnings.warn') as warn:
         flag = lbproc.flag2
     self.assertEqual(warn.call_count, 1)
     self.assertFalse(flag)
示例#28
0
 def test_double_digit_slice(self):
     lbproc = _LBProc(1234)
     with mock.patch('warnings.warn') as warn:
         digit = lbproc[1:3]
     self.assertEqual(warn.call_count, 1)
     self.assertEqual(digit, 23)
示例#29
0
 def test_true(self):
     lbproc = _LBProc(6)
     with mock.patch('warnings.warn') as warn:
         flag = lbproc.flag4
     self.assertEqual(warn.call_count, 1)
     self.assertTrue(flag)
示例#30
0
 def test(self):
     self.assertEqual(int(_LBProc(99)), 99)