Python错误NameError:未定义全局名称“user”

时间:2016-01-07 20:55:12

标签: python factory-boy

您好我是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
}

1 个答案:

答案 0 :(得分:2)

user不是全局名称,而是UserTest的属性:

def test_user_login_client(self):
    self.client.login(username=self.user.first_name, password='some')