当前位置: 首页>>代码示例>>Python>>正文


Python Sport.met方法代码示例

本文整理汇总了Python中pytrainer.core.sport.Sport.met方法的典型用法代码示例。如果您正苦于以下问题:Python Sport.met方法的具体用法?Python Sport.met怎么用?Python Sport.met使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pytrainer.core.sport.Sport的用法示例。


在下文中一共展示了Sport.met方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_met_should_accept_float_string

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import met [as 别名]
 def test_met_should_accept_float_string(self):
     sport = Sport()
     sport.name = "test1"
     sport.met = "22.5"
     self.ddbb.session.add(sport)
     self.ddbb.session.commit()
     sport = self.ddbb.session.query(Sport).filter(Sport.id == 1).one()
     self.assertEqual(22.5, sport.met)
开发者ID:pytrainer,项目名称:pytrainer,代码行数:10,代码来源:test_sport.py

示例2: test_met_should_not_accept_non_float_string

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import met [as 别名]
 def test_met_should_not_accept_non_float_string(self):
     sport = Sport()
     try:
         sport.met = "22.5kg"
     except(ValueError):
         pass
     else:
         self.fail()
开发者ID:MrBricodage,项目名称:pytrainer,代码行数:10,代码来源:sport_test.py

示例3: test_met_should_not_accept_negative_value

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import met [as 别名]
 def test_met_should_not_accept_negative_value(self):
     sport = Sport()
     try:
         sport.met = -1
     except(ValueError):
         pass
     else:
         self.fail()
开发者ID:MrBricodage,项目名称:pytrainer,代码行数:10,代码来源:sport_test.py

示例4: test_met_should_not_accept_non_float_string

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import met [as 别名]
 def test_met_should_not_accept_non_float_string(self):
     sport = Sport()
     sport.met = "22.5kg"
     try:
         self.ddbb.session.add(sport)
         self.ddbb.session.flush()
     except(ValueError, StatementError):
         pass
     else:
         self.fail()
开发者ID:pytrainer,项目名称:pytrainer,代码行数:12,代码来源:test_sport.py

示例5: test_met_should_not_accept_negative_value

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import met [as 别名]
 def test_met_should_not_accept_negative_value(self):
     if self.ddbb.engine.name == 'mysql':
         self.skipTest('Check constraints not available on Mysql')
     sport = Sport()
     sport.met = -1
     try:
         self.ddbb.session.add(sport)
         self.ddbb.session.flush()
     except (IntegrityError, InterfaceError):
         pass
     else:
         self.fail()
开发者ID:pytrainer,项目名称:pytrainer,代码行数:14,代码来源:test_sport.py

示例6: on_newsport_accept_clicked

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import met [as 别名]
 def on_newsport_accept_clicked(self,widget):
     sport = Sport()
     sport.name = gtk_str(self.newsportentry.get_text())
     sport.met = self._trim_to_null(gtk_str(self.newmetentry.get_text()))
     sport.weight = self._float_or_zero(gtk_str(self.newweightentry.get_text()))
     sport.max_pace = self._trim_to_null(gtk_str(self.newmaxpace.get_text()))
     sport.color = self.stored_color
     if sport.name.lower() in [s.name.lower() for s in self._sport_service.get_all_sports()]:
         msg = "Sport '%s' already exists" % sport.name
         logging.error(msg)
         md = Gtk.MessageDialog(None, Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, _(msg))
         md.set_title(_("Sport Creation Error"))
         md.run()
         md.destroy()
         return
     self._sport_service.store_sport(sport)
     self.pytrainer_main.refreshMainSportList()
     self.on_switch_page(None,None,2)
     self.hidesportsteps()
     self.buttonbox.set_sensitive(1)
     self.sportlist.show()
开发者ID:pytrainer,项目名称:pytrainer,代码行数:23,代码来源:windowprofile.py

示例7: on_newsport_accept_clicked

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import met [as 别名]
 def on_newsport_accept_clicked(self,widget):
     sport = Sport()
     sport.name = unicode(self.newsportentry.get_text())
     sport.met = self._trim_to_null(self.newmetentry.get_text())
     sport.weight = self.newweightentry.get_text()
     sport.max_pace = self._trim_to_null(self.newmaxpace.get_text())
     sport.color = self.stored_color
     if sport.name.lower() in [s.name.lower() for s in self._sport_service.get_all_sports()]:
         msg = "Sport '%s' already exists" % sport.name
         logging.error(msg)
         md = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, _(msg))
         md.set_title(_("Sport Creation Error"))
         md.run()
         md.destroy()
         return
     self._sport_service.store_sport(sport)
     self.parent.actualize_mainsportlist()
     self.on_switch_page(None,None,2)
     self.hidesportsteps()
     self.buttonbox.set_sensitive(1)
     self.sportlist.show()
开发者ID:rgonzalez72,项目名称:pytrainer,代码行数:23,代码来源:windowprofile.py

示例8: test_met_should_accept_float_string

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import met [as 别名]
 def test_met_should_accept_float_string(self):
     sport = Sport()
     sport.met = "22.5"
     self.assertEquals(22.5, sport.met)
开发者ID:MrBricodage,项目名称:pytrainer,代码行数:6,代码来源:sport_test.py

示例9: test_met_should_accept_float

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import met [as 别名]
 def test_met_should_accept_float(self):
     sport = Sport()
     sport.met = 22.5
     self.assertEquals(22.5, sport.met)
开发者ID:MrBricodage,项目名称:pytrainer,代码行数:6,代码来源:sport_test.py

示例10: test_met_should_accept_none

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import met [as 别名]
 def test_met_should_accept_none(self):
     sport = Sport()
     sport.met = None
     self.assertEquals(None, sport.met)
开发者ID:MrBricodage,项目名称:pytrainer,代码行数:6,代码来源:sport_test.py

示例11: test_met_should_accept_float

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import met [as 别名]
 def test_met_should_accept_float(self):
     sport = Sport()
     sport.met = 22.5
     self.ddbb.session.add(sport)
     self.ddbb.session.flush()
     self.assertEqual(22.5, sport.met)
开发者ID:pytrainer,项目名称:pytrainer,代码行数:8,代码来源:test_sport.py


注:本文中的pytrainer.core.sport.Sport.met方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。