我试图弄清楚如何将命令行参数发送到字符串中,但我不断收到错误消息。
这是我的带有命令参数的python代码
import sys
class LoginTest(unittest.TestCase):
def setUp(self):
buildURL = sys.argv[1]
self.driver = webdriver.Chrome()
self.driver.get("https://" + buildURL + "test.com")
这是我发送的命令行参数。
python test.py build190
最后是我不断收到的错误。
AttributeError: 'module' object has no attribute 'build190'
我收到的完整错误消息
Traceback (most recent call last):
File "Test.py", line 60, in <module>
unittest.main()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 94, in __init__
self.parseArgs(argv)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 149, in parseArgs
self.createTests()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 158, in createTests
self.module)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 130, in loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name in names]
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 100, in loadTestsFromName
parent, obj = obj, getattr(obj, part)
AttributeError: 'module' object has no attribute 'build190'