Esempio n. 1
0
    def test_pickling(self):
        library = FunctionLibrary(modules=[])
        library.modules = ['cp', 'xml', '_socket', 'sys', 'os']
        old_functions = library.functions

        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_functions), len(library.functions))
        os.unlink('test_library.pickle')
    def test_pickling(self):
        library = FunctionLibrary(modules=[])
        library.modules = ['cp','xml','_socket','sys','os']
        old_functions = library.functions

        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_functions), len(library.functions))
        os.unlink('test_library.pickle')
Esempio n. 3
0
def test_changing_library_functions_initializes_function_searh():

    library = FunctionLibrary(modules=['os'])

    b = Application()
    b.function_library = library
    assert_equal(b.function_search.all_functions, library.functions)

    # This forces the library to recalculate its functions.
    library.modules = ['os', 'telnetlib']
    assert_equal(b.function_search.all_functions, library.functions)
def test_changing_library_functions_initializes_function_searh():

    library = FunctionLibrary(modules=['os'])

    b = Application()
    b.function_library = library
    assert_equal(b.function_search.all_functions, library.functions)

    # This forces the library to recalculate its functions.
    library.modules = ['os', 'telnetlib']
    assert_equal(b.function_search.all_functions, library.functions)
    def test_update_all_functions_forces_new_search(self):
        library = FunctionLibrary()
        fs = FunctionSearch(all_functions=library.functions)
        self.assertEqual(len(fs.search_results), 0)

        library.modules = ["os", "sample_package"]
        # Ensure we found some functions.  This isn't a test of
        # FunctionSearch, but we want it to be true to ensure our
        # test is valid.
        self.assertNotEqual(len(library.functions), 0)

        # Now ensure the search results are updated and have something
        # in them.
        fs.all_functions = library.functions
        self.assertNotEqual(len(fs.search_results), 0)
Esempio n. 6
0
    def test_update_all_functions_forces_new_search(self):
        library = FunctionLibrary()
        fs = FunctionSearch(all_functions=library.functions)
        self.assertEqual(len(fs.search_results), 0)

        library.modules = ['os', 'sample_package']
        # Ensure we found some functions.  This isn't a test of
        # FunctionSearch, but we want it to be true to ensure our
        # test is valid.
        self.assertNotEqual(len(library.functions), 0)

        # Now ensure the search results are updated and have something
        # in them.
        fs.all_functions = library.functions
        self.assertNotEqual(len(fs.search_results), 0)