在测试多个响应时,我多次调用函数。我问的是如何在程序的早期调用一个函数,在这个函数中更改一个变量,然后调用它。下面是一段代码。在
class AbsoluteMove(unittest.TestCase):
def Ssh(self):
p=pexpect.spawn('ssh user@10.10.10.10')
self.command = './ptzpanposition -c 0 -u degx10'
p.sendline("cd /bin")
i=p.expect('user@user-NA:')
p.sendline(self.command)
i=p.expect('user@-userNA:')
self.Value = p.before
class VerifyTilt(AbsoluteMove):
def runTest(self):
self.dest.PanTilt._y=2.0
try:
result = self.client.service.AbsoluteMove(self.token, self.dest, self.speed)
except suds.WebFault as detail:
print detail
self.command = './ptzpanposition -c 0 -u degx10'
AbsoluteMove.Ssh(self)
# Position of the camera verified through Ssh (No decimal point added to the Ssh value)
self.assertEqual(self.Value, '20')
我想换个自我命令'变量输入绝对移动.Ssh(),然后运行此函数。有人知道怎么做吗?在
谢谢你的帮助
能不能给绝对移动增加一个参数?在
看起来是这样的自我命令只是一根线,而且绝对移动.Ssh()不带参数,它必须以某种方式使用该字符串…,因此您可以只更改自我命令. 一个更好的设计应该有两个命令和一个绝对移动.Ssh()在他们之间做出选择。在
您需要有一个runTest函数的包装器。注意,我在
runTest
中注释了self.command='./ptzpanposition -c 0 -u degx10'
相关问题 更多 >
编程相关推荐