我的 Mac 上安装了 python 2.7。(通过在终端中运行 python -v 验证)当我尝试使用任何新的 2.7 断言方法时,我得到 AtributeError。我查看了http://docs.python.org/2/library/unittest.html并找不到任何东西。2.6 附带的断言都可以使用 Ex Self.AssertEqual (x,x)
下面是我的代码。当我调用 assertIn 时,我收到以下消息。
* Test complete (ERROR): test012_Add_user2 (__main__.TestSuite)
(<type 'exceptions.AttributeError'>, AttributeError("'TestSuite' object has no attribute 'assertIn'",), <traceback object at 0x3>)
Traceback (most recent call last):
File "/Users/drlazor/Documents/AIM/7-16/oscar/qa/clients/TRAVOLTA/scripts_iphone/Add_Favorites.sikuli/Add_Favorites.py", line 112, in test012_Add_user2
self.assertIn (foo, foo2)
AttributeError: 'TestSuite' object has no attribute 'assertIn'
下面是我的代码
import unittest
import datetime
from sikuli import *
scriptName = os.path.basename(sys.argv[0])
addImagePath( os.path.join("scripts", scriptName) )
class TestSuite (unittest.TestCase):
#Need to add some Iphone clearing of favorites
def test001_start_IPhone(self):
logger.info (" Start aim iphone application")
showEnvironmentSettings()
a.startApp()
version = a.login(username1, password)
myTest.results['deviceVersion'] = version
wait(2)
def test012_Add_user2(self):
logger.info ("Add User 2 to the Favorites")
a.mFriends_Favorites_addNewFavs((username3[-3:]))
Fav=a.mFriends_Favorites_getAllFavs()
logger.info("assertin is tried.... will see")
#assertIn(Fav, Fav2)
self.assertIn ("foo", "foo2") #foo
for item in Fav:
logger.info (item)
logger.info ("HSJDKSKJDHSAKJDHSAKJDHSA LOOOP 2")
if (username3[-3:])not in item:
logger.info(item)
logger.info(username3[-3:])
logger.info ("dkfjlfjskl FOUND 062")
self.assert ("The screenName %s was not added to the list" %username3)
def test016_Ck_Favorite_presence(self):
pres=a.mFriends_Favorites_checkUserPresence(username3[-3:])
self.assertEqual( pres, 'Offline' )
logger.info("Presence state is '%s'" %pres)
if __name__ == '__main__':
logger.info("Running test: "+scriptName)
a = IPHONE()
b = BROWSER()
c = SAWS()
myTest = TestSuiteRunner(TestSuite, scriptName, testDescription, device=device)
myTest.runtest()