summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_inspect.py
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2007-11-06 11:44:48 (GMT)
committerChristian Heimes <christian@cheimes.de>2007-11-06 11:44:48 (GMT)
commita3538ebfe3120cf7478f91bd76674234b8cffda8 (patch)
tree6627282e35b8882fbb1ac33da7916920e7cdb5fc /Lib/test/test_inspect.py
parent7767711f543b39a5a5e2e377e0eee33a0e50f700 (diff)
downloadcpython-a3538ebfe3120cf7478f91bd76674234b8cffda8.zip
cpython-a3538ebfe3120cf7478f91bd76674234b8cffda8.tar.gz
cpython-a3538ebfe3120cf7478f91bd76674234b8cffda8.tar.bz2
Fixed bug #1384 Windows fix for inspect tests
Thanks to Amaury Forgeot d'Arc for fixing my patch ;-)
Diffstat (limited to 'Lib/test/test_inspect.py')
-rw-r--r--Lib/test/test_inspect.py32
1 files changed, 20 insertions, 12 deletions
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index 75bd408..ab733fc 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -4,6 +4,7 @@ import unittest
import inspect
import datetime
import collections
+from os.path import normcase
from test.test_support import TESTFN, run_unittest
@@ -21,6 +22,13 @@ modfile = mod.__file__
if modfile.endswith(('c', 'o')):
modfile = modfile[:-1]
+# Normalize file names: on Windows, the case of file names of compiled
+# modules depends on the path used to start the python executable.
+modfile = normcase(modfile)
+
+def revise(filename, *args):
+ return (normcase(filename),) + args
+
import __builtin__
try:
@@ -88,23 +96,23 @@ class TestInterpreterStack(IsTestBase):
def test_stack(self):
self.assert_(len(mod.st) >= 5)
- self.assertEqual(mod.st[0][1:],
+ self.assertEqual(revise(*mod.st[0][1:]),
(modfile, 16, 'eggs', [' st = inspect.stack()\n'], 0))
- self.assertEqual(mod.st[1][1:],
+ self.assertEqual(revise(*mod.st[1][1:]),
(modfile, 9, 'spam', [' eggs(b + d, c + f)\n'], 0))
- self.assertEqual(mod.st[2][1:],
+ self.assertEqual(revise(*mod.st[2][1:]),
(modfile, 43, 'argue', [' spam(a, b, c)\n'], 0))
- self.assertEqual(mod.st[3][1:],
+ self.assertEqual(revise(*mod.st[3][1:]),
(modfile, 39, 'abuse', [' self.argue(a, b, c)\n'], 0))
def test_trace(self):
self.assertEqual(len(git.tr), 3)
- self.assertEqual(git.tr[0][1:], (modfile, 43, 'argue',
- [' spam(a, b, c)\n'], 0))
- self.assertEqual(git.tr[1][1:], (modfile, 9, 'spam',
- [' eggs(b + d, c + f)\n'], 0))
- self.assertEqual(git.tr[2][1:], (modfile, 18, 'eggs',
- [' q = y / 0\n'], 0))
+ self.assertEqual(revise(*git.tr[0][1:]),
+ (modfile, 43, 'argue', [' spam(a, b, c)\n'], 0))
+ self.assertEqual(revise(*git.tr[1][1:]),
+ (modfile, 9, 'spam', [' eggs(b + d, c + f)\n'], 0))
+ self.assertEqual(revise(*git.tr[2][1:]),
+ (modfile, 18, 'eggs', [' q = y / 0\n'], 0))
def test_frame(self):
args, varargs, varkw, locals = inspect.getargvalues(mod.fr)
@@ -198,8 +206,8 @@ class TestRetrievingSourceCode(GetSourceBase):
self.assertSourceEqual(mod.StupidGit, 21, 46)
def test_getsourcefile(self):
- self.assertEqual(inspect.getsourcefile(mod.spam), modfile)
- self.assertEqual(inspect.getsourcefile(git.abuse), modfile)
+ self.assertEqual(normcase(inspect.getsourcefile(mod.spam)), modfile)
+ self.assertEqual(normcase(inspect.getsourcefile(git.abuse)), modfile)
def test_getfile(self):
self.assertEqual(inspect.getfile(mod.StupidGit), mod.__file__)