Python future_builtins.oct() Examples

The following are 13 code examples of future_builtins.oct(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module future_builtins , or try the search function .
Example #1
Source File: test_file.py    From jarvis with GNU General Public License v2.0 6 votes vote down vote up
def test_access_token_credentials(self):
        access_token = 'foo'
        user_agent = 'refresh_checker/1.0'

        credentials = client.AccessTokenCredentials(access_token, user_agent)

        storage = file_module.Storage(FILENAME)
        credentials = storage.put(credentials)
        credentials = storage.get()

        self.assertIsNotNone(credentials)
        self.assertEquals('foo', credentials.access_token)

        self.assertTrue(os.path.exists(FILENAME))

        if os.name == 'posix':  # pragma: NO COVER
            mode = os.stat(FILENAME).st_mode
            self.assertEquals('0o600', oct(stat.S_IMODE(mode))) 
Example #2
Source File: test_future_builtins.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_oct(self):
        self.assertEqual(oct(0), '0o0')
        self.assertEqual(oct(100), '0o144')
        self.assertEqual(oct(100L), '0o144')
        self.assertEqual(oct(-100), '-0o144')
        self.assertEqual(oct(-100L), '-0o144')
        self.assertRaises(TypeError, oct, ()) 
Example #3
Source File: test_future_builtins.py    From BinderFilter with MIT License 5 votes vote down vote up
def test_oct(self):
        self.assertEqual(oct(0), '0o0')
        self.assertEqual(oct(100), '0o144')
        self.assertEqual(oct(100L), '0o144')
        self.assertEqual(oct(-100), '-0o144')
        self.assertEqual(oct(-100L), '-0o144')
        self.assertRaises(TypeError, oct, ()) 
Example #4
Source File: test_future_builtins.py    From oss-ftp with MIT License 5 votes vote down vote up
def test_oct(self):
        self.assertEqual(oct(0), '0o0')
        self.assertEqual(oct(100), '0o144')
        self.assertEqual(oct(100L), '0o144')
        self.assertEqual(oct(-100), '-0o144')
        self.assertEqual(oct(-100L), '-0o144')
        self.assertRaises(TypeError, oct, ()) 
Example #5
Source File: test_future_builtins.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_oct(self):
        self.assertEqual(oct(0), '0o0')
        self.assertEqual(oct(100), '0o144')
        self.assertEqual(oct(100L), '0o144')
        self.assertEqual(oct(-100), '-0o144')
        self.assertEqual(oct(-100L), '-0o144')
        self.assertRaises(TypeError, oct, ()) 
Example #6
Source File: future_builtins.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def oct(arg):
    result = _builtin_oct(arg).rstrip('L')
    if result == '0':
        return '0o0'
    i = result.index('0') + 1
    return result[:i] + 'o' + result[i:] 
Example #7
Source File: future_builtins.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def oct(arg):
    result = _builtin_oct(arg).rstrip('L')
    if result == '0':
        return '0o0'
    i = result.index('0') + 1
    return result[:i] + 'o' + result[i:] 
Example #8
Source File: test_future_builtins.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test_oct(self):
        self.assertEqual(oct(0), '0o0')
        self.assertEqual(oct(100), '0o144')
        self.assertEqual(oct(100L), '0o144')
        self.assertEqual(oct(-100), '-0o144')
        self.assertEqual(oct(-100L), '-0o144')
        self.assertRaises(TypeError, oct, ()) 
Example #9
Source File: future_builtins.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def oct(arg):
    result = _builtin_oct(arg).rstrip('L')
    if result == '0':
        return '0o0'
    i = result.index('0') + 1
    return result[:i] + 'o' + result[i:] 
Example #10
Source File: future_builtins.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def oct(arg):
    result = _builtin_oct(arg).rstrip('L')
    if result == '0':
        return '0o0'
    i = result.index('0') + 1
    return result[:i] + 'o' + result[i:] 
Example #11
Source File: test_future_builtins.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_oct(self):
        self.assertEqual(oct(0), '0o0')
        self.assertEqual(oct(100), '0o144')
        self.assertEqual(oct(100L), '0o144')
        self.assertEqual(oct(-100), '-0o144')
        self.assertEqual(oct(-100L), '-0o144')
        self.assertRaises(TypeError, oct, ()) 
Example #12
Source File: python26.py    From ironpython2 with Apache License 2.0 4 votes vote down vote up
def test_pep19546():
    '''
    Just a small sanity test.  CPython's test_int.py covers this PEP quite 
    well.
    '''
    #Octal
    AreEqual(0O21, 17)
    AreEqual(021, 0o21)
    AreEqual(0O21, 0o21)
    AreEqual(0o0, 0)
    AreEqual(-0o1, -1)
    AreEqual(0o17777777776, 2147483646)
    AreEqual(0o17777777777, 2147483647)
    AreEqual(0o20000000000, 2147483648)
    AreEqual(-0o17777777777, -2147483647)
    AreEqual(-0o20000000000, -2147483648)
    AreEqual(-0o20000000001, -2147483649)
    
    #Binary
    AreEqual(0B11, 3)
    AreEqual(0B11, 0b11)
    AreEqual(0b0, 0)
    AreEqual(-0b1, -1)
    AreEqual(0b1111111111111111111111111111110, 2147483646)
    AreEqual(0b1111111111111111111111111111111, 2147483647)
    AreEqual(0b10000000000000000000000000000000, 2147483648)
    AreEqual(-0b1111111111111111111111111111111, -2147483647)
    AreEqual(-0b10000000000000000000000000000000, -2147483648)
    AreEqual(-0b10000000000000000000000000000001, -2147483649)
    
    #bin and future_builtins.oct
    from future_builtins import oct as fb_oct
    test_cases = [  (0B11, "0b11", "0o3"),
                    (2147483648, "0b10000000000000000000000000000000", "0o20000000000"),
                    (-2147483649L, "-0b10000000000000000000000000000001", "-0o20000000001"),
                    (-1L,          "-0b1", "-0o1"),
                    (-0b10000000000000000000000000000000, "-0b10000000000000000000000000000000", "-0o20000000000"),
                    (-0o17777777777, "-0b1111111111111111111111111111111", "-0o17777777777"),
                    (0o17777777777, "0b1111111111111111111111111111111", "0o17777777777"),
                    ]
    for val, bin_exp, oct_exp in test_cases:
        AreEqual(bin(val), bin_exp)
        AreEqual(fb_oct(val), oct_exp) 
Example #13
Source File: python26.py    From ironpython3 with Apache License 2.0 4 votes vote down vote up
def test_pep19546():
    '''
    Just a small sanity test.  CPython's test_int.py covers this PEP quite 
    well.
    '''
    #Octal
    AreEqual(0O21, 17)
    AreEqual(021, 0o21)
    AreEqual(0O21, 0o21)
    AreEqual(0o0, 0)
    AreEqual(-0o1, -1)
    AreEqual(0o17777777776, 2147483646)
    AreEqual(0o17777777777, 2147483647)
    AreEqual(0o20000000000, 2147483648)
    AreEqual(-0o17777777777, -2147483647)
    AreEqual(-0o20000000000, -2147483648)
    AreEqual(-0o20000000001, -2147483649)
    
    #Binary
    AreEqual(0B11, 3)
    AreEqual(0B11, 0b11)
    AreEqual(0b0, 0)
    AreEqual(-0b1, -1)
    AreEqual(0b1111111111111111111111111111110, 2147483646)
    AreEqual(0b1111111111111111111111111111111, 2147483647)
    AreEqual(0b10000000000000000000000000000000, 2147483648)
    AreEqual(-0b1111111111111111111111111111111, -2147483647)
    AreEqual(-0b10000000000000000000000000000000, -2147483648)
    AreEqual(-0b10000000000000000000000000000001, -2147483649)
    
    #bin and future_builtins.oct
    from future_builtins import oct as fb_oct
    test_cases = [  (0B11, "0b11", "0o3"),
                    (2147483648, "0b10000000000000000000000000000000", "0o20000000000"),
                    (-2147483649L, "-0b10000000000000000000000000000001", "-0o20000000001"),
                    (-1L,          "-0b1", "-0o1"),
                    (-0b10000000000000000000000000000000, "-0b10000000000000000000000000000000", "-0o20000000000"),
                    (-0o17777777777, "-0b1111111111111111111111111111111", "-0o17777777777"),
                    (0o17777777777, "0b1111111111111111111111111111111", "0o17777777777"),
                    ]
    for val, bin_exp, oct_exp in test_cases:
        AreEqual(bin(val), bin_exp)
        AreEqual(fb_oct(val), oct_exp)