13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
17
"""Tests for plugins"""
454
455
delattr(bzrlib.plugins, 'myplug')
458
class TestPluginFromZip(TestCaseInTempDir):
460
def make_zipped_plugin(self, zip_name, filename):
461
z = zipfile.ZipFile(zip_name, 'w')
462
z.writestr(filename, PLUGIN_TEXT)
465
def check_plugin_load(self, zip_name, plugin_name):
466
self.assertFalse(plugin_name in dir(bzrlib.plugins),
467
'Plugin already loaded')
468
old_path = bzrlib.plugins.__path__
470
# this is normally done by load_plugins -> set_plugins_path
471
bzrlib.plugins.__path__ = [zip_name]
472
self.applyDeprecated(one_three,
473
bzrlib.plugin.load_from_zip, zip_name)
474
self.assertTrue(plugin_name in dir(bzrlib.plugins),
475
'Plugin is not loaded')
478
if getattr(bzrlib.plugins, plugin_name, None):
479
delattr(bzrlib.plugins, plugin_name)
480
del sys.modules['bzrlib.plugins.' + plugin_name]
481
bzrlib.plugins.__path__ = old_path
483
def test_load_module(self):
484
self.make_zipped_plugin('./test.zip', 'ziplug.py')
485
self.check_plugin_load('./test.zip', 'ziplug')
487
def test_load_package(self):
488
self.make_zipped_plugin('./test.zip', 'ziplug/__init__.py')
489
self.check_plugin_load('./test.zip', 'ziplug')
457
492
class TestSetPluginsPath(TestCase):
459
494
def test_set_plugins_path(self):