码迷,mamicode.com
首页 > 编程语言 > 详细

python nose测试

时间:2018-01-06 19:02:58      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:.com   self   test   bag   com   info   obj   rom   安装   

前提:

  1. python3
  2. 安装nose

结果:

nose目录下有子目录tests和mybag,在mybag下新建my_age.py, 内部有Students类,age属性。

tests目录下写Sutdents类的age属性测试

测试:nosetests








 

答案:

my_age.py

class Student(object):

    @property
    def birth(self):
        return self._birth

    @birth.setter
    def birth(self, value):
        self._birth = value

my_age_test.py

from nose.tools import assert_equal
from ..mybag.my_age import Student


def test_Student():
    s = Student()
    s.birth = "123"
    assert_equal(s.birth, ‘123‘)

目录:

技术分享图片

 

python nose测试

标签:.com   self   test   bag   com   info   obj   rom   安装   

原文地址:https://www.cnblogs.com/birdofparadise/p/8214821.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!