Python optparse 模块,_parse_num() 实例源码

我们从Python开源项目中,提取了以下16个代码示例,用于说明如何使用optparse._parse_num()

项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def test_parse_num_fail(self):
        self.assertRaises(
            _parse_num, ("", int), {},
            ValueError,
            re.compile(r"invalid literal for int().*: '?'?"))
        self.assertRaises(
            _parse_num, ("0xOoops", int), {},
            ValueError,
            re.compile(r"invalid literal for int().*: s?'?0xOoops'?"))
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def test_parse_num_ok(self):
        self.assertEqual(_parse_num("0", int), 0)
        self.assertEqual(_parse_num("0x10", int), 16)
        self.assertEqual(_parse_num("0XA", int), 10)
        self.assertEqual(_parse_num("010", int), 8)
        self.assertEqual(_parse_num("0b11", int), 3)
        self.assertEqual(_parse_num("0b", int), 0)
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_parse_num_fail(self):
        self.assertRaises(
            _parse_num, ("", int), {},
            ValueError,
            re.compile(r"invalid literal for int().*: '?'?"))
        self.assertRaises(
            _parse_num, ("0xOoops", long), {},
            ValueError,
            re.compile(r"invalid literal for long().*: '?0xOoops'?"))
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_parse_num_ok(self):
        self.assertEqual(_parse_num("0", int), 0)
        self.assertEqual(_parse_num("0x10", int), 16)
        self.assertEqual(_parse_num("0XA", long), 10L)
        self.assertEqual(_parse_num("010", long), 8L)
        self.assertEqual(_parse_num("0b11", int), 3)
        self.assertEqual(_parse_num("0b", long), 0L)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_parse_num_fail(self):
        self.assertRaises(
            _parse_num, ("", int), {},
            ValueError,
            re.compile(r"invalid literal for int().*: '?'?"))
        self.assertRaises(
            _parse_num, ("0xOoops", long), {},
            ValueError,
            re.compile(r"invalid literal for long().*: '?0xOoops'?"))
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_parse_num_ok(self):
        self.assertEqual(_parse_num("0", int), 0)
        self.assertEqual(_parse_num("0x10", int), 16)
        self.assertEqual(_parse_num("0XA", long), 10L)
        self.assertEqual(_parse_num("010", long), 8L)
        self.assertEqual(_parse_num("0b11", int), 3)
        self.assertEqual(_parse_num("0b", long), 0L)
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def test_parse_num_fail(self):
        self.assertRaises(
            _parse_num, ("", int), {},
            ValueError,
            re.compile(r"invalid literal for int().*: '?'?"))
        self.assertRaises(
            _parse_num, ("0xOoops", int), {},
            ValueError,
            re.compile(r"invalid literal for int().*: s?'?0xOoops'?"))
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def test_parse_num_ok(self):
        self.assertEqual(_parse_num("0", int), 0)
        self.assertEqual(_parse_num("0x10", int), 16)
        self.assertEqual(_parse_num("0XA", int), 10)
        self.assertEqual(_parse_num("010", int), 8)
        self.assertEqual(_parse_num("0b11", int), 3)
        self.assertEqual(_parse_num("0b", int), 0)
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def test_parse_num_fail(self):
        self.assertRaises(
            _parse_num, ("", int), {},
            ValueError,
            re.compile(r"invalid literal for int().*: '?'?"))
        self.assertRaises(
            _parse_num, ("0xOoops", long), {},
            ValueError,
            re.compile(r"invalid literal for long().*: '?0xOoops'?"))
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def test_parse_num_ok(self):
        self.assertEqual(_parse_num("0", int), 0)
        self.assertEqual(_parse_num("0x10", int), 16)
        self.assertEqual(_parse_num("0XA", long), 10L)
        self.assertEqual(_parse_num("010", long), 8L)
        self.assertEqual(_parse_num("0b11", int), 3)
        self.assertEqual(_parse_num("0b", long), 0L)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_parse_num_fail(self):
        self.assertRaises(
            _parse_num, ("", int), {},
            ValueError,
            re.compile(r"invalid literal for int().*: '?'?"))
        self.assertRaises(
            _parse_num, ("0xOoops", int), {},
            ValueError,
            re.compile(r"invalid literal for int().*: s?'?0xOoops'?"))
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_parse_num_ok(self):
        self.assertEqual(_parse_num("0", int), 0)
        self.assertEqual(_parse_num("0x10", int), 16)
        self.assertEqual(_parse_num("0XA", int), 10)
        self.assertEqual(_parse_num("010", int), 8)
        self.assertEqual(_parse_num("0b11", int), 3)
        self.assertEqual(_parse_num("0b", int), 0)
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def test_parse_num_fail(self):
        self.assertRaises(
            _parse_num, ("", int), {},
            ValueError,
            re.compile(r"invalid literal for int().*: '?'?"))
        self.assertRaises(
            _parse_num, ("0xOoops", long), {},
            ValueError,
            re.compile(r"invalid literal for long().*: '?0xOoops'?"))
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def test_parse_num_ok(self):
        self.assertEqual(_parse_num("0", int), 0)
        self.assertEqual(_parse_num("0x10", int), 16)
        self.assertEqual(_parse_num("0XA", long), 10L)
        self.assertEqual(_parse_num("010", long), 8L)
        self.assertEqual(_parse_num("0b11", int), 3)
        self.assertEqual(_parse_num("0b", long), 0L)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_parse_num_fail(self):
        self.assertRaises(
            _parse_num, ("", int), {},
            ValueError,
            re.compile(r"invalid literal for int().*: '?'?"))
        self.assertRaises(
            _parse_num, ("0xOoops", int), {},
            ValueError,
            re.compile(r"invalid literal for int().*: s?'?0xOoops'?"))
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_parse_num_ok(self):
        self.assertEqual(_parse_num("0", int), 0)
        self.assertEqual(_parse_num("0x10", int), 16)
        self.assertEqual(_parse_num("0XA", int), 10)
        self.assertEqual(_parse_num("010", int), 8)
        self.assertEqual(_parse_num("0b11", int), 3)
        self.assertEqual(_parse_num("0b", int), 0)