def test_glance_main_emptyname_delete_byid(self): self.common_start() self.assertTrue(self._IMG_ID is not None) self.assertTrue(len(self._IMG_ID) > 0) self.assertTrue(glance.main(['-v', '-d', self._IMG_ID])) self.assertFalse(glance.glance_exists(self._IMG_ID)) self.assertFalse(glance.glance_exists(self._IMG_NAME))
''' 作者:lg 日期:2019/10/29 文件描述: 缺陷: ''' # import glance # 分析:只有glance被加载到内存里,这里要注意:glance如果是包,会执行包里的__init__文件 # import glance.api.policy # 分析:glance.api.policy作为一个有结构的内存空间,整体被导入到当前命名空间里.注意:使用时,要从最外层的命名空间里开始!!!!! # glance.api.policy.get() # from glance.api import policy # 分析:只有policy被加载到内存了,from只是寻找路径过程,glance不在内存里 # policy.get() # from glance.api.policy import get # get() # 分析:把方法直接导入到当前命名空间里 import glance glance.api glance.main() # from manage.py glance.get() # from policy.py glance.glance_other.say_hi.say_hello() # from say_hi
''' get create_resource main register_models ''' import sys,os # sys.path.append('/home/zzl/PycharmProjects/py_fullstack_s4/day35/aaa') # print(sys.path) print(__file__) base_dir=os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append('%s/aaa' %(base_dir)) # from aaa import glance # glance.get() import glance glance.get() glance.main()
def test_glance_main_fail_wrong_param_name(self): self.common_start() with self.assertRaises(SystemExit): with utils.devnull('stderr'): glance.main([self._IMG_NAME]) self.assertTrue(glance.glance_exists(self._IMG_NAME))
def test_glance_main_fail_listing_ids(self): with utils.environ('OS_PASSWORD', ''): self.assertFalse(glance.main([]))
def test_glance_main_ok_verbose(self): self.common_start() self.assertTrue(glance.main(['-v', '-d', self._IMG_NAME])) self.assertFalse(glance.glance_exists(self._IMG_NAME))
def test_glance_main_ok_nodelete(self): self.common_start() self.assertTrue(glance.main(['-v'])) self.assertTrue(glance.glance_exists(self._IMG_NAME))