~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_plugins.py

Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
91
91
                delattr(plugin, submodule_name)
92
92
 
93
93
    def assertPluginUnknown(self, name):
94
 
        self.failIf(getattr(bzrlib.plugins, name, None) is not None)
95
 
        self.failIf('bzrlib.plugins.%s' % name in sys.modules)
 
94
        self.assertFalse(getattr(bzrlib.plugins, name, None) is not None)
 
95
        self.assertFalse('bzrlib.plugins.%s' % name in sys.modules)
96
96
 
97
97
    def assertPluginKnown(self, name):
98
 
        self.failUnless(getattr(bzrlib.plugins, name, None) is not None)
99
 
        self.failUnless('bzrlib.plugins.%s' % name in sys.modules)
 
98
        self.assertTrue(getattr(bzrlib.plugins, name, None) is not None)
 
99
        self.assertTrue('bzrlib.plugins.%s' % name in sys.modules)
100
100
 
101
101
 
102
102
class TestLoadingPlugins(BaseTestPlugins):
109
109
        # file name we can use which is also a valid attribute for accessing in
110
110
        # activeattributes. - we cannot give import parameters.
111
111
        tempattribute = "0"
112
 
        self.failIf(tempattribute in self.activeattributes)
 
112
        self.assertFalse(tempattribute in self.activeattributes)
113
113
        # set a place for the plugins to record their loading, and at the same
114
114
        # time validate that the location the plugins should record to is
115
115
        # valid and correct.
116
116
        self.__class__.activeattributes [tempattribute] = []
117
 
        self.failUnless(tempattribute in self.activeattributes)
 
117
        self.assertTrue(tempattribute in self.activeattributes)
118
118
        # create two plugin directories
119
119
        os.mkdir('first')
120
120
        os.mkdir('second')
147
147
        self.assertPluginUnknown('plugin')
148
148
 
149
149
    def test_plugins_from_different_dirs_can_demand_load(self):
150
 
        self.failIf('bzrlib.plugins.pluginone' in sys.modules)
151
 
        self.failIf('bzrlib.plugins.plugintwo' in sys.modules)
 
150
        self.assertFalse('bzrlib.plugins.pluginone' in sys.modules)
 
151
        self.assertFalse('bzrlib.plugins.plugintwo' in sys.modules)
152
152
        # This test tests that having two plugins in different
153
153
        # directories with different names allows them both to be loaded, when
154
154
        # we do a direct import statement.
155
155
        # Determine a file name we can use which is also a valid attribute
156
156
        # for accessing in activeattributes. - we cannot give import parameters.
157
157
        tempattribute = "different-dirs"
158
 
        self.failIf(tempattribute in self.activeattributes)
 
158
        self.assertFalse(tempattribute in self.activeattributes)
159
159
        # set a place for the plugins to record their loading, and at the same
160
160
        # time validate that the location the plugins should record to is
161
161
        # valid and correct.
162
162
        bzrlib.tests.test_plugins.TestLoadingPlugins.activeattributes \
163
163
            [tempattribute] = []
164
 
        self.failUnless(tempattribute in self.activeattributes)
 
164
        self.assertTrue(tempattribute in self.activeattributes)
165
165
        # create two plugin directories
166
166
        os.mkdir('first')
167
167
        os.mkdir('second')
186
186
 
187
187
        oldpath = bzrlib.plugins.__path__
188
188
        try:
189
 
            self.failIf('bzrlib.plugins.pluginone' in sys.modules)
190
 
            self.failIf('bzrlib.plugins.plugintwo' in sys.modules)
 
189
            self.assertFalse('bzrlib.plugins.pluginone' in sys.modules)
 
190
            self.assertFalse('bzrlib.plugins.plugintwo' in sys.modules)
191
191
            bzrlib.plugins.__path__ = ['first', 'second']
192
192
            exec "import bzrlib.plugins.pluginone"
193
193
            self.assertEqual(['first'], self.activeattributes[tempattribute])
208
208
        # check the plugin is not loaded already
209
209
        self.assertPluginUnknown('ts_plugin')
210
210
        tempattribute = "trailing-slash"
211
 
        self.failIf(tempattribute in self.activeattributes)
 
211
        self.assertFalse(tempattribute in self.activeattributes)
212
212
        # set a place for the plugin to record its loading, and at the same
213
213
        # time validate that the location the plugin should record to is
214
214
        # valid and correct.
215
215
        bzrlib.tests.test_plugins.TestLoadingPlugins.activeattributes \
216
216
            [tempattribute] = []
217
 
        self.failUnless(tempattribute in self.activeattributes)
 
217
        self.assertTrue(tempattribute in self.activeattributes)
218
218
        # create a directory for the plugin
219
219
        os.mkdir('plugin_test')
220
220
        # write a plugin that will record when its loaded in the