summaryrefslogtreecommitdiff
path: root/astroid/tests/unittest_modutils.py
diff options
context:
space:
mode:
authorClaudiu Popa <cpopa@cloudbasesolutions.com>2015-03-30 21:46:38 +0300
committerClaudiu Popa <cpopa@cloudbasesolutions.com>2015-03-30 21:46:38 +0300
commitf188f3e61022c173d62c9e1609ce5983c0153971 (patch)
tree582f218058a80593b0cda208ab952b24620b5169 /astroid/tests/unittest_modutils.py
parent7173dd95e2d4628191705629865409fef872cea2 (diff)
downloadastroid-git-f188f3e61022c173d62c9e1609ce5983c0153971.tar.gz
Add some fixes which enhances the Jython support.
The fix mostly includes updates to modutils, which is modified in order to properly lookup paths from live objects, which ends in $py.class, not pyc as for Python 2, Closes issue #83.
Diffstat (limited to 'astroid/tests/unittest_modutils.py')
-rw-r--r--astroid/tests/unittest_modutils.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/astroid/tests/unittest_modutils.py b/astroid/tests/unittest_modutils.py
index 61391a50..e62ffe64 100644
--- a/astroid/tests/unittest_modutils.py
+++ b/astroid/tests/unittest_modutils.py
@@ -27,6 +27,10 @@ from astroid import modutils
from astroid.tests import resources
+def _get_file_from_object(obj):
+ return modutils._path_from_filename(obj.__file__)
+
+
class ModuleFileTest(unittest.TestCase):
package = "mypypa"
@@ -122,8 +126,9 @@ class FileFromModPathTest(resources.SysPathSetup, unittest.TestCase):
if it exists"""
def test_site_packages(self):
- self.assertEqual(os.path.realpath(modutils.file_from_modpath(['astroid', 'modutils'])),
- os.path.realpath(modutils.__file__.replace('.pyc', '.py')))
+ filename = _get_file_from_object(modutils)
+ result = modutils.file_from_modpath(['astroid', 'modutils'])
+ self.assertEqual(os.path.realpath(result), filename)
def test_std_lib(self):
from os import path
@@ -157,8 +162,9 @@ class FileFromModPathTest(resources.SysPathSetup, unittest.TestCase):
class GetSourceFileTest(unittest.TestCase):
def test(self):
+ filename = _get_file_from_object(os.path)
self.assertEqual(modutils.get_source_file(os.path.__file__),
- os.path.normpath(os.path.__file__.replace('.pyc', '.py')))
+ os.path.normpath(filename))
def test_raise(self):
self.assertRaises(modutils.NoSourceFile, modutils.get_source_file, 'whatever')