def test_basic(self): import sys mod = ModuleWrapper('sys') self.assertEquals(sys.version_info, mod.version_info) self.assertTrue('_current_frames' in sys.__dict__) # by default, names with a leading underscore are not available self.assertTrue('_current_frames' not in mod._LX_names())
def test_unreadable(self): import math settings = {'unreadable_names': set(('tan','atan',))} mod = ModuleWrapper('math', settings) self.assertEquals(math.sin, mod.sin) self.assertEquals(math.cos, mod.cos) self.assertEquals(math.fabs, mod.fabs) self.assertTrue('tan' in math.__dict__) self.assertTrue('atan' in math.__dict__) self.assertTrue('tan' not in mod._LX_names()) self.assertTrue('atan' not in mod._LX_names())
def test_module_with_submodules(self): import os import os.path osmod = ModuleWrapper('os') self.assertTrue('path' in os.__dict__) self.assertTrue('path' not in osmod._LX_names()) pathmod = ModuleWrapper('os.path') osmod._LX_add_submodule('os.path', pathmod) self.assertTrue('path' in osmod._LX_names()) self.assertEquals(pathmod, osmod.path) #==============================================================================#
def test_module_with_all(self): import csv #settings = {'readable_names': set(('sin','cos',))} mod = ModuleWrapper('csv') self.assertEquals(csv.writer, mod.writer) self.assertEquals(csv.reader, mod.reader) self.assertTrue('re' in csv.__dict__) self.assertTrue('re' not in mod._LX_names()) self.assertTrue('_Dialect' in csv.__dict__) self.assertTrue('_Dialect' not in mod._LX_names()) self.assertTrue('reduce' in csv.__dict__) self.assertTrue('reduce' not in mod._LX_names())