sys.hexversion

Here are the examples of the python api sys.hexversion taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

200 Examples 7

Example 1

View license
def versionok_for_gui():
    ''' Return True if running Python is suitable for GUI Event Integration and deeper IPython integration '''
    # We require Python 2.6+ ...
    if sys.hexversion < 0x02060000:
        return False
    # Or Python 3.2+
    if sys.hexversion >= 0x03000000 and sys.hexversion < 0x03020000:
        return False
    # Not supported under Jython nor IronPython
    if sys.platform.startswith("java") or sys.platform.startswith('cli'):
        return False

    return True

Example 2

Project: filmkodi
Source File: pydev_versioncheck.py
View license
def versionok_for_gui():
    ''' Return True if running Python is suitable for GUI Event Integration and deeper IPython integration '''
    # We require Python 2.6+ ...
    if sys.hexversion < 0x02060000:
        return False
    # Or Python 3.2+
    if sys.hexversion >= 0x03000000 and sys.hexversion < 0x03020000:
        return False
    # Not supported under Jython nor IronPython
    if sys.platform.startswith("java") or sys.platform.startswith('cli'):
        return False

    return True

Example 3

Project: ganeti
Source File: tempfile_fork_unittest.py
View license
  def testNoReset(self):
    if ((sys.hexversion >= 0x020703F0 and sys.hexversion < 0x03000000) or
        sys.hexversion >= 0x030203F0):
      # We can't test the no_reset case on Python 2.7+
      return
    # evil Debian sid...
    if (hasattr(tempfile._RandomNameSequence, "rng") and
        type(tempfile._RandomNameSequence.rng) == property):
      return
    self._Test(False)

Example 4

Project: numba
Source File: ddt.py
View license
def is_hash_randomized():
    return (((sys.hexversion >= 0x02070300 and
              sys.hexversion < 0x03000000) or
             (sys.hexversion >= 0x03020300)) and
            sys.flags.hash_randomization and
            'PYTHONHASHSEED' not in os.environ)

Example 5

Project: numba
Source File: ddt.py
View license
def is_hash_randomized():
    return (((sys.hexversion >= 0x02070300 and
              sys.hexversion < 0x03000000) or
             (sys.hexversion >= 0x03020300)) and
            sys.flags.hash_randomization and
            'PYTHONHASHSEED' not in os.environ)

Example 6

Project: filmkodi
Source File: pydev_versioncheck.py
View license
def versionok_for_gui():
    ''' Return True if running Python is suitable for GUI Event Integration and deeper IPython integration '''
    # We require Python 2.6+ ...
    if sys.hexversion < 0x02060000:
        return False
    # Or Python 3.2+
    if sys.hexversion >= 0x03000000 and sys.hexversion < 0x03020000:
        return False
    # Not supported under Jython nor IronPython
    if sys.platform.startswith("java") or sys.platform.startswith('cli'):
        return False

    return True

Example 7

Project: glymur
Source File: openjpeg.py
View license
def version():
    """Wrapper for opj_version library routine."""
    OPENJPEG.opj_version.restype = ctypes.c_char_p
    library_version = OPENJPEG.opj_version()
    if sys.hexversion >= 0x03000000:
        return library_version.decode('utf-8')
    else:
        return library_version

Example 8

Project: py12306
Source File: hook-PyQt5.uic.port_v2.py
View license
def hook(mod):
    # Forbid imports in the port_v2 directory under Python 3
    # The code wouldn't import and would crash the build process.
    if sys.hexversion >= 0x03000000:
        mod.__path__ = []
    return mod

Example 9

Project: WAPT
Source File: testShell.py
View license
    def testComplex(self):
        if sys.hexversion < 0x2030000:
            # no kw-args to dict in 2.2 - not worth converting!
            return
        clsid = pythoncom.MakeIID("{CD637886-DB8B-4b04-98B5-25731E1495BE}")
        ctime, atime, wtime = self._getTestTimes()
        d = dict(cFileName="foo.txt",
                 clsid=clsid,
                 sizel=(1,2),
                 pointl=(3,4),
                 dwFileAttributes = win32con.FILE_ATTRIBUTE_NORMAL,
                 ftCreationTime=ctime,
                 ftLastAccessTime=atime,
                 ftLastWriteTime=wtime,
                 nFileSize=sys_maxsize + 1)
        self._testRT(d)

Example 10

Project: pelisalacarta
Source File: downloader.py
View license
    def __get_download_headers__(self):
      for x in range(3):
        print ("Conectando con el servidor...")
        try:
          if not sys.hexversion > 0x0204FFFF:
            conn = urllib2.urlopen(urllib2.Request(self.url, headers=self._headers))
            conn.fp._sock.close()
          else:
            conn = urllib2.urlopen(urllib2.Request(self.url, headers=self._headers), timeout=5)
            
        except:
          self.response_headers = dict()
          self._state = self.states.error
          print ("Error al conectar con el servidor")
        else:
          self.response_headers = conn.headers.dict
          self._state = self.states.stopped
          break

Example 11

Project: py12306
Source File: hook-PyQt4.uic.port_v2.py
View license
def hook(mod):
    # Forbid imports in the port_v2 directory under Python 3
    # The code wouldn't import and would crash the build process.
    if sys.hexversion >= 0x03000000:
        mod.__path__ = []
    return mod

Example 12

Project: pyliblo
Source File: test_liblo.py
View license
    def testSendVarious(self):
        self.server.add_method('/blah', 'ihfdscb', self.callback)
        if sys.hexversion < 0x03000000:
            self.server.send(1234, '/blah', 123, 2**42, 123.456, 666.666, "hello", ('c', 'x'), (12, 34, 56))
        else:
            self.server.send(1234, '/blah', 123, ('h', 2**42), 123.456, 666.666, "hello", ('c', 'x'), (12, 34, 56))
        self.assertTrue(self.server.recv())
        self.assertEqual(self.cb.types, 'ihfdscb')
        self.assertEqual(len(self.cb.args), len(self.cb.types))
        self.assertEqual(self.cb.args[0], 123)
        self.assertEqual(self.cb.args[1], 2**42)
        self.assertAlmostEqual(self.cb.args[2], 123.456, 3)
        self.assertAlmostEqual(self.cb.args[3], 666.666, 3)
        self.assertEqual(self.cb.args[4], "hello")
        self.assertEqual(self.cb.args[5], 'x')
        if sys.hexversion < 0x03000000:
            self.assertEqual(self.cb.args[6], [12, 34, 56])
        else:
            self.assertEqual(self.cb.args[6], b'\x0c\x22\x38')

Example 13

Project: klepto
Source File: tools.py
View license
def _b(message):
    """convert string to correct format for buffer object"""
    import sys
    if hex(sys.hexversion) >= '0x30000f0':
        import codecs
        return codecs.latin_1_encode(message)[0]
    return message

Example 14

Project: ExoData
Source File: astroclasses.py
View license
def _createMagConversionDict():
    """ loads magnitude_conversion.dat which is table A% 1995ApJS..101..117K
    """
    magnitude_conversion_filepath = resource_stream(__name__, 'data/magnitude_conversion.dat')
    raw_table = np.loadtxt(magnitude_conversion_filepath, '|S5')

    magDict = {}
    for row in raw_table:
        if sys.hexversion >= 0x03000000:
            starClass = row[1].decode("utf-8")  # otherwise we get byte ints or b' caused by 2to3
            tableData = [x.decode("utf-8") for x in row[3:]]
        else:
            starClass = row[1]
            tableData = row[3:]
        magDict[starClass] = tableData

    return magDict

Example 15

Project: mythbox
Source File: runtime.py
View license
def shortPythonVersion():
    hv = sys.hexversion
    major = (hv & 0xff000000L) >> 24
    minor = (hv & 0x00ff0000L) >> 16
    teeny = (hv & 0x0000ff00L) >> 8
    return "%s.%s.%s" % (major,minor,teeny)

Example 16

Project: brickv
Source File: esp_flash.py
View license
def unhexify(hs):
    s = []
    for i in range(0, len(hs) - 1, 2):
        s.append(int(hs[i] + hs[i + 1], 16))
    if sys.hexversion < 0x03000000:
        return ''.join(map(chr, s))
    else:
        return bytes(s)

Example 17

Project: jc-weather
Source File: alfred_weather.py
View license
    def tell_about(self, name, query='', prefix=None):
        import sys
        import json

        with open('update.json', 'rt') as uf:
            data = json.load(uf)
        items = [Item('Version: {0}'.format(data['version']))]
        py_ver = 'Python: {:08X}'.format(sys.hexversion)
        items.append(Item(py_ver))

        return items

Example 18

Project: TrustRouter
Source File: testShell.py
View license
    def testComplex(self):
        if sys.hexversion < 0x2030000:
            # no kw-args to dict in 2.2 - not worth converting!
            return
        clsid = pythoncom.MakeIID("{CD637886-DB8B-4b04-98B5-25731E1495BE}")
        ctime, atime, wtime = self._getTestTimes()
        d = dict(cFileName="foo.txt",
                 clsid=clsid,
                 sizel=(1,2),
                 pointl=(3,4),
                 dwFileAttributes = win32con.FILE_ATTRIBUTE_NORMAL,
                 ftCreationTime=ctime,
                 ftLastAccessTime=atime,
                 ftLastWriteTime=wtime,
                 nFileSize=sys_maxsize + 1)
        self._testRT(d)

Example 19

Project: girder
Source File: base.py
View license
    @classmethod
    def u(cls, s):
        if sys.hexversion < 0x03000000 and isinstance(s, str):
            s = s.decode('utf-8')
        if sys.hexversion >= 0x03000000 and isinstance(s, bytes):
            s = s.decode('utf-8')
        return s

Example 20

Project: packet-manipulator
Source File: core.py
View license
    def open_url(self, link):
        """
        Open the default browser at link location

        @param link the link to open
        """

        import webbrowser

        new = 0
        if sys.hexversion >= 0x2050000:
            new = 2

        webbrowser.open(link, new=new)

Example 21

Project: skytools
Source File: scripting.py
View license
def _load_log_config(fn, defs):
    """Fixed fileConfig."""

    # Work around fileConfig default behaviour to disable
    # not only old handlers on load (which slightly makes sense)
    # but also old logger objects (which does not make sense).

    if sys.hexversion >= 0x2060000:
        logging.config.fileConfig(fn, defs, False)
    else:
        logging.config.fileConfig(fn, defs)
        root = logging.getLogger()
        for lg in root.manager.loggerDict.values():
            lg.disabled = 0

Example 22

Project: mfp
Source File: unit.py
View license
    def testSendVarious(self):
        self.server.add_method('/blah', 'ihfdscb', self.callback)
        if sys.hexversion < 0x03000000:
            self.server.send(1234, '/blah', 123, 2**42, 123.456, 666.666, "hello", ('c', 'x'), (12, 34, 56))
        else:
            self.server.send(1234, '/blah', 123, ('h', 2**42), 123.456, 666.666, "hello", ('c', 'x'), (12, 34, 56))
        assert self.server.recv() == True
        assert self.cb.types == 'ihfdscb'
        assert len(self.cb.args) == len(self.cb.types)
        assert self.cb.args[0] == 123
        assert self.cb.args[1] == 2**42
        assert approx(self.cb.args[2], 123.456)
        assert approx(self.cb.args[3], 666.666)
        assert self.cb.args[4] == "hello"
        assert self.cb.args[5] == 'x'
        if sys.hexversion < 0x03000000:
            assert self.cb.args[6] == [12, 34, 56]
        else:
            assert self.cb.args[6] == b'\x0c\x22\x38'

Example 23

Project: blackhole
Source File: setup_helpers.py
View license
def require_python(minimum):
    if sys.hexversion < minimum:
        hversion = hex(minimum)[2:]
        if len(hversion) % 2 != 0:
            hversion = '0' + hversion
        split = list(hversion)
        parts = []
        while split:
            parts.append(int(''.join((split.pop(0), split.pop(0))), 16))
        major, minor, micro, release = parts
        if release == 0xf0:
            print('Python {0}.{1}.{2} or better is required'.format(
                major, minor, micro))
        else:
            print('Python {0}.{1}.{2} ({3}) or better is required'.format(
                major, minor, micro, hex(release)[2:]))
        sys.exit(1)

Example 24

Project: blackhole
Source File: setup_helpers.py
View license
def require_python(minimum):
    if sys.hexversion < minimum:
        hversion = hex(minimum)[2:]
        if len(hversion) % 2 != 0:
            hversion = '0' + hversion
        split = list(hversion)
        parts = []
        while split:
            parts.append(int(''.join((split.pop(0), split.pop(0))), 16))
        major, minor, micro, release = parts
        if release == 0xf0:
            print('Python {0}.{1}.{2} or better is required'.format(
                major, minor, micro))
        else:
            print('Python {0}.{1}.{2} ({3}) or better is required'.format(
                major, minor, micro, hex(release)[2:]))
        sys.exit(1)

Example 25

Project: numscons
Source File: misc.py
View license
def get_pythonlib_name(debug = 0):
    """Return the name of python library (necessary to link on NT with
    mingw."""
    # Yeah, distutils burried the link option on NT deep down in
    # Extension module, we cannot reuse it !
    if debug == 1:
        template = 'python%d%d_d'
    else:
        template = 'python%d%d'

    return template % (sys.hexversion >> 24,
                       (sys.hexversion >> 16) & 0xff)

Example 26

Project: baidu_http_pan
Source File: 360yun.py
View license
    @classmethod
    def u(cls, s):
        if sys.hexversion < 0x03000000 and isinstance(s, str):
            s = s.decode('utf-8')
        if sys.hexversion >= 0x03000000 and isinstance(s, bytes):
            s = s.decode('utf-8')
        return s

Example 27

Project: pyliblo
Source File: test_liblo.py
View license
    def testSendBlob(self):
        self.server.add_method('/blob', 'b', self.callback)
        self.server.send('1234', '/blob', [4, 8, 15, 16, 23, 42])
        self.assertTrue(self.server.recv())
        if sys.hexversion < 0x03000000:
            self.assertEqual(self.cb.args[0], [4, 8, 15, 16, 23, 42])
        else:
            self.assertEqual(self.cb.args[0], b'\x04\x08\x0f\x10\x17\x2a')

Example 28

Project: nzbToMedia
Source File: dumprar.py
View license
def xprint(m, *args):
    if sys.hexversion < 0x3000000:
        m = m.decode('utf8')
    if args:
        m = m % args
    if sys.hexversion < 0x3000000:
        m = m.encode('utf8')
    sys.stdout.write(m)
    sys.stdout.write('\n')

Example 29

Project: qutebrowser
Source File: checkpyver.py
View license
def check_python_version():
    """Check if correct python version is run."""
    if sys.hexversion < 0x03040000:
        # We don't use .format() and print_function here just in case someone
        # still has < 2.6 installed.
        # pylint: disable=bad-builtin
        version_str = '.'.join(map(str, sys.version_info[:3]))
        text = ("At least Python 3.4 is required to run qutebrowser, but " +
                version_str + " is installed!\n")
        if Tk and '--no-err-windows' not in sys.argv:  # pragma: no cover
            root = Tk()
            root.withdraw()
            messagebox.showerror("qutebrowser: Fatal error!", text)
        else:
            sys.stderr.write(text)
            sys.stderr.flush()
        sys.exit(1)

Example 30

Project: mythbox
Source File: test_advice.py
View license
    def checkDoubleType(self):
        if sys.hexversion >= 0x02030000:
            return  # you can't duplicate bases in 2.3
        class aType(type,type):
            ping([],1)
        aType, = aType
        self.assert_(aType.__class__ is type)

Example 31

Project: mythbox
Source File: runtime.py
View license
def shortPythonVersion():
    hv = sys.hexversion
    major = (hv & 0xff000000L) >> 24
    minor = (hv & 0x00ff0000L) >> 16
    teeny = (hv & 0x0000ff00L) >> 8
    return "%s.%s.%s" % (major,minor,teeny)

Example 32

Project: mythbox
Source File: test_advice.py
View license
    def checkDoubleType(self):
        if sys.hexversion >= 0x02030000:
            return  # you can't duplicate bases in 2.3
        class aType(type,type):
            ping([],1)
        aType, = aType
        self.assert_(aType.__class__ is type)

Example 33

Project: ExoData
Source File: equations.py
View license
def _createMagConversionDict():
    """Loads magnitude_conversion.dat which is table A% 1995ApJS..101..117K
    """
    magnitude_conversion_filepath = resource_stream(
        __name__, 'data/magnitude_conversion.dat')
    raw_table = np.loadtxt(magnitude_conversion_filepath, '|S5')

    magDict = {}
    for row in raw_table:
        if sys.hexversion >= 0x03000000:
            # otherwise we get byte ints or b' caused by 2to3
            starClass = row[1].decode("utf-8")
            tableData = [x.decode("utf-8") for x in row[3:]]
        else:
            starClass = row[1]
            tableData = row[3:]
        magDict[starClass] = tableData

    return magDict

Example 34

Project: py12306
Source File: hook-PyQt5.uic.port_v3.py
View license
def hook(mod):
    # Forbid imports in the port_v3 directory under Python 2
    # The code wouldn't import and would crash the build process.
    if sys.hexversion < 0x03000000:
        mod.__path__ = []
    return mod

Example 35

Project: py12306
Source File: hook-PyQt4.uic.port_v3.py
View license
def hook(mod):
    # Forbid imports in the port_v3 directory under Python 2
    # The code wouldn't import and would crash the build process.
    if sys.hexversion < 0x03000000:
        mod.__path__ = []
    return mod

Example 36

Project: compmake
Source File: manager_multiprocessing.py
View license
    def process_init(self):
        Shared.event_queue = Queue(self.num_processes * 1000)
        # info('Starting %d processes' % self.num_processes)
        kwargs = {}

        if sys.hexversion >= 0x02070000:
            # added in 2.7.2
            kwargs['maxtasksperchild'] = 1

        self.pool = Pool(processes=self.num_processes,
                         initializer=worker_initialization,
                         **kwargs)
        self.max_num_processing = self.num_processes

Example 37

Project: compmake
Source File: manager_multiprocessing.py
View license
    def process_init(self):
        Shared.event_queue = Queue(self.num_processes * 1000)
        # info('Starting %d processes' % self.num_processes)
        kwargs = {}

        if sys.hexversion >= 0x02070000:
            # added in 2.7.2
            kwargs['maxtasksperchild'] = 1

        self.pool = Pool(processes=self.num_processes,
                         initializer=worker_initialization,
                         **kwargs)
        self.max_num_processing = self.num_processes

Example 38

Project: rarfile
Source File: dumprar.py
View license
def xprint(m, *args):
    """Print string to stdout.

    Format unicode safely.
    """
    if sys.hexversion < 0x3000000:
        m = m.decode('utf8')
    if args:
        m = m % args
    if sys.hexversion < 0x3000000:
        m = m.encode('utf8')
    sys.stdout.write(m)
    sys.stdout.write('\n')

Example 39

Project: rarfile
Source File: dumprar.py
View license
def xprint(m, *args):
    """Print string to stdout.

    Format unicode safely.
    """
    if sys.hexversion < 0x3000000:
        m = m.decode('utf8')
    if args:
        m = m % args
    if sys.hexversion < 0x3000000:
        m = m.encode('utf8')
    sys.stdout.write(m)
    sys.stdout.write('\n')

Example 40

Project: pelisalacarta
Source File: downloader.py
View license
    def __open_connection__(self, start, end):
      headers = self._headers.copy()
      if not end: end = ""
      headers.update({"Range": "bytes=%s-%s" % (start, end)})
      if not sys.hexversion > 0x0204FFFF:
        conn = urllib2.urlopen(urllib2.Request(self.url, headers=headers))
      else:
        conn = urllib2.urlopen(urllib2.Request(self.url, headers=headers), timeout=5)
      return conn

Example 41

Project: bilibili-live-kit
Source File: __main__.py
View license
def main():
    if sys.hexversion < 0x3050000:
        print('requires Python 3.5+.')
        exit(-1)
    if not os.path.exists('configure.json'):
        print('please "configure.json" configuration file.')
        exit(-1)
    start_service()

Example 42

Project: skytools
Source File: scripting.py
View license
def _load_log_config(fn, defs):
    """Fixed fileConfig."""

    # Work around fileConfig default behaviour to disable
    # not only old handlers on load (which slightly makes sense)
    # but also old logger objects (which does not make sense).

    if sys.hexversion >= 0x2060000:
        logging.config.fileConfig(fn, defs, False)
    else:
        logging.config.fileConfig(fn, defs)
        root = logging.getLogger()
        for lg in root.manager.loggerDict.values():
            lg.disabled = 0

Example 43

Project: mfp
Source File: unit.py
View license
    def testSendBlob(self):
        self.server.add_method('/blob', 'b', self.callback)
        self.server.send('1234', '/blob', [4, 8, 15, 16, 23, 42])
        assert self.server.recv() == True
        if sys.hexversion < 0x03000000:
            assert self.cb.args[0] == [4, 8, 15, 16, 23, 42]
        else:
            assert self.cb.args[0] == b'\x04\x08\x0f\x10\x17\x2a'

Example 44

Project: SickRage
Source File: dumprar.py
View license
def xprint(m, *args):
    if sys.hexversion < 0x3000000:
        m = m.decode('utf8')
    if args:
        m = m % args
    if sys.hexversion < 0x3000000:
        m = m.encode('utf8')
    sys.stdout.write(m)
    sys.stdout.write('\n')

Example 45

Project: ruffus
Source File: test_graphviz.py
View license
    def test_graphviz_dot(self):
        """Make sure annotations from graphviz appear in dot
        """

        if sys.hexversion >= 0x03000000:
            # everything is unicode in python3
            s = BytesIO()
        else:
            s = StringIO()


        pipeline_printout_graph (
                                        s,
                                        # use flowchart file name extension to decide flowchart format
                                        #   e.g. svg, jpg etc.
                                        "dot",
                                        [Final_target, Up_to_date_final_target], pipeline= "main")
        self.assertTrue('[URL="http://cnn.com", color="#FF0000", fillcolor="#FFCCCC", fontcolor="#4B6000", height=1.5, label=<What is this?<BR/> What <FONT COLOR="red">is</FONT>this???>, pencolor="#FF0000", peripheries=5, shape=component, style=dashed]' in s.getvalue().decode())

Example 46

View license
    def setUp(self):
        try:
            os.mkdir(tempdir)
        except OSError:
            pass
        if sys.hexversion < 0x03000000:
            self.assertRaisesRegex = self.assertRaisesRegexp27

        if sys.hexversion < 0x02700000:
            self.assertIn = self.my_assertIn

Example 47

Project: PyBitmessage
Source File: depends.py
View license
def check_hashlib():
    if sys.hexversion < 0x020500F0:
        logger.error('The hashlib module is not included in this version of Python.')
        return False
    import hashlib
    if '_hashlib' not in hashlib.__dict__:
        logger.error('The RIPEMD-160 hash algorithm is not available. The hashlib module is not linked against OpenSSL.')
        return False
    try:
        hashlib.new('ripemd160')
    except ValueError:
        logger.error('The RIPEMD-160 hash algorithm is not available. The hashlib module utilizes an OpenSSL library with RIPEMD disabled.')
        return False
    return True

Example 48

Project: pycscope
Source File: testissues.py
View license
    def testIssue0009(self):
        """ Verify dumpCst works on tuples.
        """
        try:
            from cStringIO import StringIO
        except ImportError:
            from io import StringIO
        out = StringIO()
        import parser, sys
        cst = parser.suite("import sys\na = b\n")
        pycscope.dumpCst(cst.totuple(True), out)
        output = out.getvalue()
        if sys.hexversion < 0x03000000:
            expected = "['file_input',\n ['stmt',\n  ['simple_stmt',\n   ['small_stmt',\n    ['import_stmt',\n     ['import_name',\n      ['NAME', 'import', 1],\n      ['dotted_as_names',\n       ['dotted_as_name', ['dotted_name', ['NAME', 'sys', 1]]]]]]],\n   ['NEWLINE', '', 1]]],\n ['stmt',\n  ['simple_stmt',\n   ['small_stmt',\n    ['expr_stmt',\n     ['testlist',\n      ['test',\n       ['or_test',\n        ['and_test',\n         ['not_test',\n          ['comparison',\n           ['expr',\n            ['xor_expr',\n             ['and_expr',\n              ['shift_expr',\n               ['arith_expr',\n                ['term',\n                 ['factor',\n                  ['power', ['atom', ['NAME', 'a', 2]]]]]]]]]]]]]]]],\n     ['EQUAL', '=', 2],\n     ['testlist',\n      ['test',\n       ['or_test',\n        ['and_test',\n         ['not_test',\n          ['comparison',\n           ['expr',\n            ['xor_expr',\n             ['and_expr',\n              ['shift_expr',\n               ['arith_expr',\n                ['term',\n                 ['factor',\n                  ['power', ['atom', ['NAME', 'b', 2]]]]]]]]]]]]]]]]]],\n   ['NEWLINE', '', 2]]],\n ['NEWLINE', '', 2],\n ['ENDMARKER', '', 2]]\n"
        else:
            expected = "['file_input',\n ['stmt',\n  ['simple_stmt',\n   ['small_stmt',\n    ['import_stmt',\n     ['import_name',\n      ['NAME', 'import', 1],\n      ['dotted_as_names',\n       ['dotted_as_name', ['dotted_name', ['NAME', 'sys', 1]]]]]]],\n   ['NEWLINE', '', 1]]],\n ['stmt',\n  ['simple_stmt',\n   ['small_stmt',\n    ['expr_stmt',\n     ['testlist_star_expr',\n      ['test',\n       ['or_test',\n        ['and_test',\n         ['not_test',\n          ['comparison',\n           ['expr',\n            ['xor_expr',\n             ['and_expr',\n              ['shift_expr',\n               ['arith_expr',\n                ['term',\n                 ['factor',\n                  ['power', ['atom', ['NAME', 'a', 2]]]]]]]]]]]]]]]],\n     ['EQUAL', '=', 2],\n     ['testlist_star_expr',\n      ['test',\n       ['or_test',\n        ['and_test',\n         ['not_test',\n          ['comparison',\n           ['expr',\n            ['xor_expr',\n             ['and_expr',\n              ['shift_expr',\n               ['arith_expr',\n                ['term',\n                 ['factor',\n                  ['power', ['atom', ['NAME', 'b', 2]]]]]]]]]]]]]]]]]],\n   ['NEWLINE', '', 2]]],\n ['NEWLINE', '', 2],\n ['ENDMARKER', '', 2]]\n"
        print(repr(output))
        self.assertEqual(output, expected)

Example 49

Project: picard
Source File: test_bytes2human.py
View license
    def setUp(self):
        # we are using temporary locales for tests
        self.tmp_path = tempfile.mkdtemp().decode("utf-8")
        if sys.hexversion >= 0x020700F0:
            self.addCleanup(shutil.rmtree, self.tmp_path)
        self.localedir = os.path.join(self.tmp_path, 'locale')

Example 50

Project: picard
Source File: test_bytes2human.py
View license
    def setUp(self):
        # we are using temporary locales for tests
        self.tmp_path = tempfile.mkdtemp().decode("utf-8")
        if sys.hexversion >= 0x020700F0:
            self.addCleanup(shutil.rmtree, self.tmp_path)
        self.localedir = os.path.join(self.tmp_path, 'locale')