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