Python optparse._parse_num() Examples

The following are 20 code examples of optparse._parse_num(). 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 optparse , or try the search function .
Example #1
Source File: test_optparse.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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'?")) 
Example #2
Source File: test_optparse.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #3
Source File: test_optparse.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
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'?")) 
Example #4
Source File: test_optparse.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #5
Source File: test_optparse.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
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'?")) 
Example #6
Source File: test_optparse.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
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) 
Example #7
Source File: test_optparse.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
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'?")) 
Example #8
Source File: test_optparse.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #9
Source File: test_optparse.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
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'?")) 
Example #10
Source File: test_optparse.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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) 
Example #11
Source File: test_optparse.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
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'?")) 
Example #12
Source File: test_optparse.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
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) 
Example #13
Source File: test_optparse.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
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'?")) 
Example #14
Source File: test_optparse.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #15
Source File: test_optparse.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
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'?")) 
Example #16
Source File: test_optparse.py    From oss-ftp with MIT License 5 votes vote down vote up
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) 
Example #17
Source File: test_optparse.py    From oss-ftp with MIT License 5 votes vote down vote up
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'?")) 
Example #18
Source File: test_optparse.py    From BinderFilter with MIT License 5 votes vote down vote up
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) 
Example #19
Source File: test_optparse.py    From BinderFilter with MIT License 5 votes vote down vote up
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'?")) 
Example #20
Source File: test_optparse.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
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)