本文整理汇总了Python中user.User.setName方法的典型用法代码示例。如果您正苦于以下问题:Python User.setName方法的具体用法?Python User.setName怎么用?Python User.setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类user.User
的用法示例。
在下文中一共展示了User.setName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MainWindow
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import setName [as 别名]
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.user = User()
self.initUI()
def initUI(self):
self.createActions()
self.createMenus()
self.mainWidget = MainWidget(self.user)
self.setCentralWidget(self.mainWidget)
self.setGeometry(300, 300, 300, 200)
self.setWindowTitle('Chatomaniac')
self.show()
def createActions(self):
self.exitAction = QAction(QIcon('exit.png'), '&Exit', self)
self.exitAction.setShortcut('Ctrl+Q')
self.exitAction.setStatusTip('Exit application')
self.exitAction.triggered.connect(qApp.quit)
self.editUserAction = QAction(QIcon('user.png'), '&User', self)
self.editUserAction.setShortcut('Ctrl+U')
self.editUserAction.setStatusTip('Edit user data')
self.editUserAction.triggered.connect(self.editUserName)
self.archieveAction = QAction( '&Archieve', self)
self.archieveAction.setShortcut('Ctrl+A')
self.archieveAction.setStatusTip('Show archieve')
self.archieveAction.triggered.connect(self.showArchieve)
def createMenus(self):
self.menubar = self.menuBar()
self.fileMenu = self.menubar.addMenu('&File')
self.fileMenu.addAction(self.exitAction)
self.userMenu = self.menubar.addMenu('&User')
self.userMenu.addAction(self.editUserAction)
self.archieveMenu = self.menubar.addMenu('Archieve')
self.archieveMenu.addAction(self.archieveAction)
def editUserName(self):
text, ok = QInputDialog.getText(self, 'Name change dialog', 'Please, enter your name:', text=self.user.name)
self.user.setName(text)
def showArchieve(self):
archieveDialog = ArchieveDialog(self, self.mainWidget.db)
archieveDialog.exec_()
def closeEvent(self,event):
print("zamykamy")
if sys.argv[1] != "test":
self.mainWidget.db.close()
event.accept()
示例2: User
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import setName [as 别名]
import unittest
from datetime import datetime
from user import User
uname = '[email protected]'
password = 'superpanda'
user = User(uname, password)
user.setName('Awesome Unicorn')
glist0 = {"items":['spinach, 1 bunch','corn, 4 can'],"gname":"grocery list 1"}
glist1 = {"items":['broccli, 1 bunch','peas, 2 bag'],"gname":"grocery list 2"}
glist2 = {"items":['chicken, 1 whole','corn, 4 can'],"gname":"grocery list 3"}
glist3 = {"items":['carrot, 1 bunch','peas, 2 bag'],"gname":"grocery list 4"}
glists = [glist0,glist1,glist2,glist3]
user.updateGLists(glists)
print(user.getName())
print("Grocery Lists")
print(user.getGLists())
示例3: UserTest
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import setName [as 别名]
class UserTest(unittest.TestCase):
def setUp(self):
self.glistNames = ["grocery list 1", "grocery list 2", "grocery list 3", "grocery list 4"]
self.itemsList = [
["spinach, 1 bunch", "corn, 4 can"],
["broccli, 1 bunch", "peas, 2 bag"],
["chicken, 1 whole", "corn, 4 can"],
["carrot, 1 bunch", "peas, 2 bag"],
]
self.glist0 = {"items": self.itemsList[0], "gname": self.glistNames[0]}
self.glist1 = {"items": self.itemsList[1], "gname": self.glistNames[1]}
self.glist2 = {"items": self.itemsList[2], "gname": self.glistNames[2]}
self.glist3 = {"items": self.itemsList[3], "gname": self.glistNames[3]}
self.glists = [self.glist0, self.glist1, self.glist2, self.glist3]
self.name1 = "[email protected]"
self.password1 = "superpanda"
self.user1 = User(self.name1, self.password1)
self.user1.updateGLists(self.glists)
self.name2 = "DoesNotExist"
self.password2 = "DoesNotExist"
self.user2 = User(self.name2, self.password2)
def test_userExist(self):
self.assertTrue(self.user1.exist())
def test_userDoesNotExist(self):
self.assertFalse(self.user2.exist())
def test_canLogin(self):
self.assertTrue(self.user1.login())
def test_canNotLogin(self):
self.assertFalse(self.user2.login())
def test_getName(self):
self.assertEqual(self.user2.getName(), self.name2)
def test_setName(self):
newName = "Maggy"
self.user1.setName(newName)
self.assertEqual(self.user1.getName(), newName)
self.user1.setName(self.name1)
def test_getGroceryLists(self):
result = self.user1.getGLists()
self.assertIsNotNone(result)
self.user2.deleteGLists()
self.assertIsNone(self.user2.getGLists())
print("\n test_getGroceryLists:")
print(result)
def test_updateGroceryLists(self):
self.assertTrue(self.user2.updateGLists(self.glists))
result = self.user2.getGLists()
self.assertEqual(result[0]["gname"], self.glist0["gname"])
self.user2.deleteGLists()
def test_getCurrentGList(self):
self.user1.updateCurrentListIndex(1)
self.assertEqual(self.user1.getCurrentGList(), self.glist1["items"])
def test_getCurrentGlistName(self):
self.user1.updateCurrentListIndex(3)
self.assertEqual(self.user1.getCurrentGlistName(), self.glist3["gname"])
def test_getGListsNames(self):
result = self.user1.getGListsNames()
self.assertEqual(result, self.glistNames)
print("\n test_getGListsNames:")
print(result)
def test_getGListsItemList(self):
result = self.user1.getGListsItemList()
self.assertEqual(result, self.itemsList)
print("\ntest_getGListsItemList")
print(result)
def test_addNewGroceryList(self):
gname = "New Item List"
self.user1.addNewGroceryList(gname)
result = self.user1.getGListsNames()
self.assertEqual(result[-1], gname)
gl = self.user1.getGLists()
self.user1.updateGLists(self.glists)
print("\n test_addNewGroceryList:")
print(gl)
def test_addNewCurrentListItem(self):
item = "olives, 10 can"
self.user1.addNewCurrentListItem(item)
result = self.user1.getCurrentGList()
self.assertEqual(result[-1], item)
print("\n test_addNewCurrentListItem:")
print(self.user1.getGLists())
print("\n\n")
print(result)