Back to index

plone3  3.1.7
Public Member Functions | Private Member Functions | Static Private Attributes
jsbase.conftest.JSTest Class Reference

List of all members.

Public Member Functions

def run
def fail

Private Member Functions

def _handle_line
def _format_tb

Static Private Attributes

 _handling_traceback = False

Detailed Description

Definition at line 11 of file conftest.py.


Member Function Documentation

def jsbase.conftest.JSTest._format_tb (   self,
  tb 
) [private]

Definition at line 77 of file conftest.py.

00077 
00078     def _format_tb(self, tb):
00079         tb.reverse()
00080         ret = []
00081         for line in tb:
00082             line = line.strip()
00083             if not line:
00084                 continue
00085             funcsig, lineinfo = line.split('@', 1)
00086             fpath, lineno = lineinfo.rsplit(':', 1)
00087             fname = py.path.local(fpath).basename
00088             # XXX might filter out too much... but it's better than leaving it
00089             # all in (since it adds a couple of lines to the end of the tb,
00090             # making it harder to find the problem line)
00091             if fname in ['__testbase_temp.js', '__testbase_find.js',
00092                             'exception.js']: 
00093                 continue
00094             lineno = int(lineno)
00095             if lineno == 0:
00096                 fname = "<unknown>"
00097             ret.append('File "%s", line %s, in %s' % (
00098                         fname, lineno, funcsig or '?'))
00099             if lineno > 0:
00100                 line = py.path.local(fpath).readlines()[lineno - 1]
00101                 ret.append('    %s' % (line.strip(),))
00102         return '\n'.join(['  %s' % (r,) for r in ret]) 
            

Here is the caller graph for this function:

def jsbase.conftest.JSTest._handle_line (   self,
  line,
  data 
) [private]

Definition at line 56 of file conftest.py.

00056 
00057     def _handle_line(self, line, data):
00058         line = line[:-1]
00059         if line.startswith('end test'):
00060             return True
00061         if self._handling_traceback and line != 'end traceback':
00062             data[data['current']].append(line)
00063         if line.startswith('PRINTED: '):
00064             print line[9:]
00065         elif line.startswith('running test '):
00066             testname = line[13:]
00067             data['current'] = testname
00068             data[testname] = []
00069         elif line.startswith('success'):
00070             pass
00071         elif line.startswith('failure: '):
00072             data[data['current']].append(line[9:])
00073         elif line.startswith('traceback'):
00074             self._handling_traceback = True
00075         elif line.startswith('end traceback'):
00076             self._handling_traceback = False

Here is the caller graph for this function:

def jsbase.conftest.JSTest.fail (   self,
  errdata 
)

Definition at line 44 of file conftest.py.

00044 
00045     def fail(self, errdata):
00046         py.test.fail(
00047         '\nJS traceback (most recent last): \n%s\n%s\n' % (
00048                 (errdata[1:] and 
00049                     self._format_tb(errdata[1:-5]) or
00050                     'no traceback available'
00051                 ),
00052                 errdata[0], 
00053             )
00054         )

Here is the call graph for this function:

Definition at line 12 of file conftest.py.

00012 
00013     def run(self):
00014         path = self.fspath
00015         test = self.name.split('/')[-1]
00016         paths = [path.strpath, 
00017                     (here / 'exception.js').strpath,
00018                     (here / 'testing.js').strpath,
00019                     (here / 'misclib.js').strpath,
00020                 ]
00021         testjs = (here / 'testing/testbase.js').read() % (
00022                     paths, test, '__main__')
00023         curdir = str(py.path.local('.'))
00024         py.std.os.chdir(str(self.fspath.dirpath()))
00025         try:
00026             jspath = self.fspath.new(basename='__testbase_temp.js')
00027             try:
00028                 jspath.write(testjs)
00029                 pipe = py.std.os.popen('js "%s"' % (jspath,))
00030                 try:
00031                     data = {}
00032                     for line in pipe:
00033                         done = self._handle_line(line, data)
00034                         if done:
00035                             errdata = data[data['current']]
00036                             if errdata:
00037                                 self.fail(errdata)
00038                 finally:
00039                     pipe.close()
00040             finally:
00041                 jspath.remove()
00042         finally:
00043             py.std.os.chdir(curdir)

Here is the call graph for this function:


Member Data Documentation

jsbase.conftest.JSTest._handling_traceback = False [static, private]

Definition at line 55 of file conftest.py.


The documentation for this class was generated from the following file: