Strip file name from printed import paths

This commit is contained in:
Stein Magnus Jodal 2012-08-31 22:46:18 +02:00
parent 4c6a6af487
commit 4284e08d69
2 changed files with 6 additions and 3 deletions

View File

@ -1,3 +1,4 @@
import os
import sys
import pygst
@ -36,7 +37,8 @@ def format_dependency_list(adapters=None):
'version': dep_info.get('version', 'not found'),
})
if 'path' in dep_info:
lines.append(' Imported from: %(path)s' % dep_info)
lines.append(' Imported from: %s' % (
os.path.dirname(dep_info['path'])))
if 'other' in dep_info:
lines.append(' Other: %s' % (
indent(dep_info['other'])),)

View File

@ -15,7 +15,7 @@ class DepsTest(unittest.TestCase):
adapters = [
lambda: dict(name='Python', version='FooPython 2.7.3'),
lambda: dict(name='Platform', version='Loonix 4.0.1'),
lambda: dict(name='Pykka', path='/foo/bar/baz', other='Quux')
lambda: dict(name='Pykka', path='/foo/bar/baz.py', other='Quux')
]
result = deps.format_dependency_list(adapters)
@ -23,7 +23,8 @@ class DepsTest(unittest.TestCase):
self.assertIn('Python: FooPython 2.7.3', result)
self.assertIn('Platform: Loonix 4.0.1', result)
self.assertIn('Pykka: not found', result)
self.assertIn('Imported from: /foo/bar/baz', result)
self.assertIn('Imported from: /foo/bar', result)
self.assertNotIn('/baz.py', result)
self.assertIn('Quux', result)
def test_gstreamer_info(self):