예제 #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)