def test_pickling(self): library = ClassLibrary(modules=[]) library.modules = ['cp','xml','_socket','sys','os'] old_classes = library.classes import cPickle cPickle.dump(library, open(r'test_library.pickle','wb')) library = cPickle.load(open(r'test_library.pickle','rb')) library.modules = ['cp','xml','_socket','sys','os'] self.assertEqual(len(old_classes), len(library.classes)) os.unlink('test_library.pickle')
def test_update_all_classes_forces_new_search(self): library = ClassLibrary() cs = ClassSearch(all_classes=library.classes) self.assertEqual(len(cs.search_results), 0) library.modules=['datetime', 'sample_package'] # Ensure we found some classes. This isn't a test of # ClassSearch, but we want it to be true to ensure our # test is valid. self.assertNotEqual(len(library.classes), 0) # Now ensure the search results are updated and have something # in them. cs.all_classes = library.classes self.assertNotEqual(len(cs.search_results), 0)