当前位置: 首页>>代码示例>>Python>>正文


Python future_builtins.oct方法代码示例

本文整理汇总了Python中future_builtins.oct方法的典型用法代码示例。如果您正苦于以下问题:Python future_builtins.oct方法的具体用法?Python future_builtins.oct怎么用?Python future_builtins.oct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在future_builtins的用法示例。


在下文中一共展示了future_builtins.oct方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_access_token_credentials

# 需要导入模块: import future_builtins [as 别名]
# 或者: from future_builtins import oct [as 别名]
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))) 
开发者ID:haynieresearch,项目名称:jarvis,代码行数:20,代码来源:test_file.py

示例2: test_oct

# 需要导入模块: import future_builtins [as 别名]
# 或者: from future_builtins import oct [as 别名]
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, ()) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_future_builtins.py

示例3: oct

# 需要导入模块: import future_builtins [as 别名]
# 或者: from future_builtins import oct [as 别名]
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:] 
开发者ID:Acmesec,项目名称:CTFCrackTools-V2,代码行数:8,代码来源:future_builtins.py

示例4: test_pep19546

# 需要导入模块: import future_builtins [as 别名]
# 或者: from future_builtins import oct [as 别名]
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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:45,代码来源:python26.py


注:本文中的future_builtins.oct方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。