您好我是python的新手,并尝试编写工厂男孩测试,但收到此错误
self.client.login(username = user.first_name,password ='abc')
NameError:未定义全局名称“user”
import UIKit
import CVCalendar
class ViewController: UIViewController, CVCalendarViewDelegate, CVCalendarMenuViewDelegate {
@IBOutlet weak var calendarView: CVCalendarView!
@IBOutlet weak var menuView: CVCalendarMenuView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.navigationController?.navigationBar
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
calendarView.commitCalendarViewUpdate()
menuView.commitMenuViewUpdate()
}
func presentationMode() -> CalendarMode {
return CalendarMode.MonthView
}
func firstWeekday() -> Weekday {
return Weekday.Sunday
}
答案 0 :(得分:2)
user
不是全局名称,而是UserTest
的属性:
def test_user_login_client(self):
self.client.login(username=self.user.first_name, password='some')