~ubuntu-branches/ubuntu/maverick/pydb/maverick

« back to all changes in this revision

Viewing changes to test/test-with.py.in

  • Committer: Bazaar Package Importer
  • Author(s): Oleksandr Moskalenko, Sandro Tosi, Oleksandr Moskalenko
  • Date: 2009-01-26 13:44:36 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090126134436-s5hxlnnej9iolu52
Tags: 1.25-1
[Sandro Tosi]
* debian/control
  - switch Vcs-Browser field to viewsvn
[Oleksandr Moskalenko]
* New upstream release.
* debian/pydb.docs: Added upstream ChangeLog to docs (Closes: #508414).
* debian/{pydb.emacsen-install,pydb.emacsen-remove,pydb.emacsen-startup}:
  Added emacse setup files again (Closes: #493190).
* debian/control:
  - Changed Depends on emacsen-common to Suggests emacs22 (the only version
    pydb.el works with).
  - Updated standards-version and debhelper dependencies.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!@PYTHON@ -t
2
 
# $Id: test-with.py.in,v 1.3 2008/05/21 14:48:43 rockyb Exp $ -*- Python -*-
 
2
# $Id: test-with.py.in,v 1.7 2008/12/10 13:31:26 rockyb Exp $ -*- Python -*-
3
3
"""Unit test of the bug in using 'info local' when inside a "with" command."""
4
4
import difflib, os, time, sys, unittest
5
5
 
6
 
top_builddir = ".."
 
6
top_builddir = "@top_builddir@"
7
7
if top_builddir[-1] != os.path.sep:
8
8
    top_builddir += os.path.sep
9
9
sys.path.insert(0, os.path.join(top_builddir, 'pydb'))
10
 
top_srcdir = ".."
 
10
top_srcdir = "@top_srcdir@"
11
11
if top_srcdir[-1] != os.path.sep:
12
12
    top_srcdir += os.path.sep
13
13
sys.path.insert(0, os.path.join(top_srcdir, 'pydb'))
14
14
 
15
 
builddir     = "."
 
15
builddir     = "@builddir@"
16
16
if builddir[-1] != os.path.sep:
17
17
    builddir += os.path.sep
18
18
 
19
 
srcdir = "."
 
19
srcdir = "@srcdir@"
20
20
if srcdir[-1] != os.path.sep:
21
21
    srcdir += os.path.sep
22
22
 
24
24
pydb_short   = "pydb.py"
25
25
pydb_path    = os.path.join(pydir, pydb_short)
26
26
 
27
 
def run_debugger(testname, pydb_opts='', args=''):
 
27
def run_debugger(testname, pythonfile, pydb_opts='', args='', rightfile=None,
 
28
                 need_26=False):
28
29
    global srcdir, builddir, pydir
29
30
 
30
 
    rightfile   = os.path.join(builddir, "%s.right" % testname)
 
31
    if rightfile is None:
 
32
        rightfile   = os.path.join(builddir, 'data', "%s.right" % testname)
31
33
 
32
34
    os.environ['PYTHONPATH']=os.pathsep.join(sys.path)
33
 
    cmdfile     = os.path.join(builddir, "%s.cmd"   % testname)
 
35
    cmdfile     = os.path.join(srcdir, "%s.cmd"   % testname)
34
36
    outfile     = "%s.out" % testname
35
37
    outfile_opt = '--output=%s ' % outfile
36
38
 
39
41
 
40
42
    if os.path.exists(outfile): os.unlink(outfile)
41
43
 
42
 
    cmd = "%s --command %s %s %s %s %s.py" % \
43
 
          (pydb_path, cmdfile, outfile_opt, pydb_opts, args, testname)
 
44
    cmd = "%s --command %s %s %s %s %s" % \
 
45
          (pydb_path, cmdfile, outfile_opt, pydb_opts, args, pythonfile)
44
46
    
45
47
    os.system(cmd)
46
48
    fromfile  = rightfile
49
51
    tofile    = outfile
50
52
    todate    = time.ctime(os.stat(tofile).st_mtime)
51
53
    tolines   = open(tofile, 'U').readlines()[0:-1]
52
 
    tolines[4]= tolines[4][0:74] + "\n"
 
54
    if not need_26:
 
55
        tolines[4]= tolines[4][0:74] + "\n"
53
56
    diff = list(difflib.unified_diff(fromlines, tolines, fromfile,
54
57
                                     tofile, fromdate, todate))
55
58
    if len(diff) == 0:
62
65
 
63
66
    def test_with(self):
64
67
        """Test running bug running "info local" inside a "with" command"""
65
 
        if sys.version_info[0:2] == (2, 5):
66
 
            result=run_debugger(testname='withbug', pydb_opts='--basename')
 
68
        if sys.hexversion >= 0x02050000:
 
69
            if sys.hexversion >= 0x02060000:
 
70
                need_26 = True
 
71
                rightfile = os.path.join(srcdir, 'data',
 
72
                                         "withbug-2.6.right")
 
73
            else:
 
74
                need_26 = False
 
75
                rightfile = os.path.join(srcdir, 'data',
 
76
                                         "withbug.right")
 
77
            result=run_debugger(testname='withbug', 
 
78
                                pythonfile='%swithbug.py' % srcdir,
 
79
                                pydb_opts='--basename',
 
80
                                rightfile=rightfile, need_26=need_26)
67
81
            self.assertEqual(True, result, "pydb 'withbug' command comparision")
68
82
        self.assertTrue(True, 'With test skipped - not 2.5')
69
83
        return