首页 > 编程语言 > 详细

python nose测试

时间:2018-01-06 18:30:41      阅读:174      评论:0      收藏:0      [点我收藏+]

前提:

  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测试

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!