tests/run-tests.py
changeset 28126 562a073a2a1b
parent 28099 a5f0c0aab2bb
child 28127 807bc140e915
equal deleted inserted replaced
28125:3b4537ba80e9 28126:562a073a2a1b
    46 from __future__ import print_function
    46 from __future__ import print_function
    47 
    47 
    48 from distutils import version
    48 from distutils import version
    49 import difflib
    49 import difflib
    50 import errno
    50 import errno
       
    51 import json
    51 import optparse
    52 import optparse
    52 import os
    53 import os
    53 import shutil
    54 import shutil
    54 import subprocess
    55 import subprocess
    55 import signal
    56 import signal
    67     import queue
    68     import queue
    68 from xml.dom import minidom
    69 from xml.dom import minidom
    69 import unittest
    70 import unittest
    70 
    71 
    71 osenvironb = getattr(os, 'environb', os.environ)
    72 osenvironb = getattr(os, 'environb', os.environ)
    72 
       
    73 try:
       
    74     import json
       
    75 except ImportError:
       
    76     try:
       
    77         import simplejson as json
       
    78     except ImportError:
       
    79         json = None
       
    80 
       
    81 processlock = threading.Lock()
    73 processlock = threading.Lock()
    82 
    74 
    83 if sys.version_info > (3, 5, 0):
    75 if sys.version_info > (3, 5, 0):
    84     PYTHON3 = True
    76     PYTHON3 = True
    85     xrange = range # we use xrange in one place, and we'd rather not use range
    77     xrange = range # we use xrange in one place, and we'd rather not use range
  1723                         t.appendChild(cd)
  1715                         t.appendChild(cd)
  1724                         s.appendChild(t)
  1716                         s.appendChild(t)
  1725                     xuf.write(doc.toprettyxml(indent='  ', encoding='utf-8'))
  1717                     xuf.write(doc.toprettyxml(indent='  ', encoding='utf-8'))
  1726 
  1718 
  1727             if self._runner.options.json:
  1719             if self._runner.options.json:
  1728                 if json is None:
       
  1729                     raise ImportError("json module not installed")
       
  1730                 jsonpath = os.path.join(self._runner._testdir, 'report.json')
  1720                 jsonpath = os.path.join(self._runner._testdir, 'report.json')
  1731                 with open(jsonpath, 'w') as fp:
  1721                 with open(jsonpath, 'w') as fp:
  1732                     timesd = {}
  1722                     timesd = {}
  1733                     for tdata in result.times:
  1723                     for tdata in result.times:
  1734                         test = tdata[0]
  1724                         test = tdata[0]