Bug 1304593 - Fix broken test_entry_point.py in mach, r=gps

Fix and enable python/mach/mach/test/test_entry_poiny.py.

MozReview-Commit-ID: FtMpt8Nmq3g

--HG--
extra : rebase_source : 73755266b7d9570065c0ab18e0b50e074559914c
This commit is contained in:
Andrew Halberstadt 2016-09-27 17:11:00 -04:00
parent 7a1894eae5
commit fae591ac2b

View File

@ -16,6 +16,7 @@ from mozunit import main
here = os.path.abspath(os.path.dirname(__file__))
class Entry():
"""Stub replacement for pkg_resources.EntryPoint"""
def __init__(self, providers):
@ -26,6 +27,7 @@ class Entry():
return self.providers
return _providers
class TestEntryPoints(TestBase):
"""Test integrating with setuptools entry points"""
provider_dir = os.path.join(here, 'providers')
@ -41,20 +43,19 @@ class TestEntryPoints(TestBase):
mod = imp.new_module(b'mach.commands')
sys.modules[b'mach.commands'] = mod
mock.return_value = [Entry(['providers'])]
mock.return_value = [Entry([self.provider_dir])]
# Mach error raised due to conditions_invalid.py
with self.assertRaises(MachError):
self._run_mach()
@patch('pkg_resources.iter_entry_points')
def test_load_entry_point_from_file(self, mock):
mock.return_value = [Entry([os.path.join('providers', 'basic.py')])]
mock.return_value = [Entry([os.path.join(self.provider_dir, 'basic.py')])]
result, stdout, stderr = self._run_mach()
self.assertIsNone(result)
self.assertIn('cmd_foo', stdout)
# Not enabled in automation because tests are failing.
#if __name__ == '__main__':
# main()
if __name__ == '__main__':
main()