亲爱的所有人,我都在尝试在运行时导入一个 python 模块(从 admincases 导入 admincases),并在这方面遇到问题。请求您的指导。
import os
import threading
import sys
import Queue
import unittest
import time
import logging
from functions import functions
from functions import db_connect
from one import ParametrizedTestCase
#from admincases import admincases
import MySQLdb as mdb
class inittest(unittest.TestCase):
fun = functions()
db = db_connect()
cur = db.db_conn()
cur.execute ("SELECT * FROM testcase")
testcases = cur.fetchall ()
for testcase in testcases:
print "%s, %s" % (testcase[0], testcase[1])
import_string = "from " + testcase[1] + " import " + testcase[1]
print import_string
exec import_string
case = str_to_class(testcase[1])
print case
print "Number of rows returned: %d" % cur.rowcount
suite = unittest.TestSuite()
suite.addTest(ParametrizedTestCase.parametrize(case, param=EppQueue,queue1=CrQueue))
unittest.TextTestRunner(verbosity=2).run(suite)
raw_input("keyy")
执行此代码时,我收到以下错误:
return getattr(sys.modules[__name__], str)
AttributeError: 'module' object has no attribute 'admincases'
不知道是什么错误
问候文卡特.S