Ejemplo n.º 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))
Ejemplo n.º 2
0
 def test_equal_int(self):
     self.assertTrue(_LBProc(17).__eq__(17))
Ejemplo n.º 3
0
 def test_invalid_str(self):
     with self.assertRaisesRegexp(ValueError, 'invalid literal for int'):
         _LBProc('asdf')
Ejemplo n.º 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)
Ejemplo n.º 5
0
 def test_str(self):
     _LBProc('245')
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 8
0
 def test_not_equal_int(self):
     self.assertTrue(_LBProc(10).__ne__(15))
Ejemplo n.º 9
0
 def test(self):
     lbproc = _LBProc(12)
     lbproc &= 8
     self.assertEqual(int(lbproc), 8)
Ejemplo n.º 10
0
 def test_equal_int(self):
     self.assertFalse(_LBProc(8).__ne__(8))
Ejemplo n.º 11
0
 def test_not_equal(self):
     self.assertTrue(_LBProc(9).__ne__(_LBProc(14)))
Ejemplo n.º 12
0
 def test_equal(self):
     self.assertFalse(_LBProc(7).__ne__(_LBProc(7)))
Ejemplo n.º 13
0
 def test_not_equal_int(self):
     self.assertFalse(_LBProc(17).__eq__(16))
Ejemplo n.º 14
0
 def test_not_equal(self):
     self.assertFalse(_LBProc(17).__eq__(_LBProc(18)))
Ejemplo n.º 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)
Ejemplo n.º 16
0
 def test(self):
     lbproc = _LBProc(12)
     lbproc |= 1
     self.assertEqual(int(lbproc), 13)
Ejemplo n.º 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)
Ejemplo n.º 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))
Ejemplo n.º 19
0
 def test_int(self):
     _LBProc(42)
Ejemplo n.º 20
0
 def test(self):
     lbproc = _LBProc(8641)
     self.assertEqual(repr(lbproc), '_LBProc(8641)')
Ejemplo n.º 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)
Ejemplo n.º 22
0
 def test(self):
     lbproc = _LBProc(8641)
     self.assertEqual(str(lbproc), '8641')
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 30
0
 def test(self):
     self.assertEqual(int(_LBProc(99)), 99)