这几天都有遇到nosetest,一是hardway learn python中,还有一个是django中,因此想趁此了解下有什么用,看了半天也不理解具体的用处,还是老规矩把尝试的一些内容记下来。之所以叫感知,可以发现真的是没有理解,关键是中间的执行过程和执行后的作用。

官方文档:http://nose.readthedocs.org/en/latest/usage.html

《python numpy ln函数python之nosetests自动化测试框架感知》总结了关于学习Python教程,对于我们来电脑技术网确实能学到不少知识。

网上找了一个比较好点的例子,比较好理解点,不像IBM网站上的类的例子,那个看起来太绕了;

关于摄氏与华氏的转换函数:

temperature.py

def to_celsius(t):

return (t - 32.0) * 5.0 / 9.0

def above_freezing(t):

return t > 0接下来是测试脚本1,主要作用:导入了nose和temperature模块,写了两个测试函数(感觉没有动作),最后是运行模块。test_temperature.py

import nose

import temperature

def test_to_celsius():

'''Test function for to_celsius'''

pass

def test_above_freezing():

'''Test function for above_freezing.'''

pass

if __name__ == '__main__':

nose.runmodule()接下来是测试脚本2,导入了nose和celsius函数,然后定义了3个不同的值进行执行判断。test_celsius.py

import nose

from temperature import to_celsius

def test_freezing():

assert to_celsius(32) == 0

def test_boiling():

assert to_celsius(212) == 100

def test_roundoff():

assert to_celsius(100) == 38

if __name__ == '__main__':

nose.runmodule()接下来是测试脚本3,导入了nose和freezing函数,然后定义了3个不同的值进行执行判断。test_freezing.py

import nose

from temperature import above_freezing

def test_above_freezing():

assert above_freezing(89.4), 'A temperature above freezing.'

assert not above_freezing(-42), 'A temperature below freezing.'

assert not above_freezing(0), ' A temperature at freezing.'

if __name__ == '__main__':

nose.runmodule()其中运行结果如下:

先运行一遍temperature.py,然后运行test.temperature.py,如下:

root@LOonux:/home/loongson/python/nose# ls

nose_test.py test_1.py test_freezing.py

temperature.py test_celsius.py test_temperature.py

root@LOonux:/home/loongson/python/nose# python temperature.py

root@LOonux:/home/loongson/python/nose# nosetests -v test_temperature.py

Test function for to_celsius ... ok

Test function for above_freezing. ... ok

----------------------------------------------------------------------

Ran 2 tests in 0.006s

OK

root@LOonux:/home/loongson/python/nose#这两个ok只能说明都执行了吧?不知还能说明什么。接下来测试celsiusroot@LOonux:/home/loongson/python/nose# nosetests -v test_celsius.py

test_celsius.test_freezing ... ok

test_celsius.test_boiling ... ok

test_celsius.test_roundoff ... FAIL

======================================================================

FAIL: test_celsius.test_roundoff

----------------------------------------------------------------------

Traceback (most recent call last):

File "/usr/local/lib/python2.6/dist-packages/nose-1.3.0-py2.6.egg/nose/case.py", line 197, in runTest

self.test(*self.arg)

File "/home/loongson/python/nose/test_celsius.py", line 13, in test_roundoff

assert to_celsius(100) == 38

AssertionError

----------------------------------------------------------------------

Ran 3 tests in 0.010s

FAILED (failures=1)

root@LOonux:/home/loongson/python/nose#这里有一个报错,主要是小数点的问题,

>>> t =100

>>> (t - 32.0) * 5.0 / 9.0

37.77777777777778不相等,当然报错了。接下来测试freezing,

root@LOonux:/home/loongson/python/nose# nosetests -v test_freezing.py

test_freezing.test_above_freezing ... ok

----------------------------------------------------------------------

Ran 1 test in 0.006s

OK

root@LOonux:/home/loongson/python/nose#这个就一个ok,后两个因为都小于等于0,所以感觉在temperature.py中没有返回值,到这里结果就不执行了一样。

就是这个样子,真心没搞懂有什么意义,主要其它自动化测试框架也没有接触过。感觉写这个的时间比我自己测试的代价大多了,而且根本就没有测试全面。

如果你知道,请指导下!

暂时到此,以后理解了来补充。

11-18

常用命令行参数:a) -w ,指定一个目录运行测试。目录可以是相对路径或绝对路径。

例如: nosetest -w c:pythonTestsTest1,只运行目录c:pythonTestsTest1下的测试。可以指定多个目录,例如:

nosetest -wc:pythonTestsTest1 -w c:pythonTestsTest2。

更多:python numpy ln函数python之nosetests自动化测试框架感知

https://www.002pc.comhttps://www.002pc.com/python/2894.html

你可能感兴趣的python,nosetests,感知,自动化,框架,测试

No alive nodes found in your cluster

0踩

0 赞

python怎么运行ln函数_python numpy ln函数python之nosetests自动化测试框架感知相关推荐

  1. python row函数_Python numpy 常用函数总结

    Numpy是什么 在没给大家介绍numpy之前先给大家说下python的基本概念. Python 是一种高级的,动态的,多泛型的编程语言.Python代码很多时候看起来就像是伪代码一样,因此你可以使用 ...

  2. python排大小函数_python numpy 一些函数 大小排序和统计

    排序大小函数 import numpy as np size = 100 a = np.random.randint(0, 1000, size=size) print(a) # 排序之后的前k个元素 ...

  3. [转载] python histogram函数_Python numpy.histogram_bin_edges函数方法的使用

    参考链接: Python中的numpy.ceil numpy.histogram_bin_edges numpy.histogram_bin_edges(a, bins=10, range=None, ...

  4. python中isin函数_Python numpy.isin函数方法的使用

    numpy.isin numpy.isin(element, test_elements, assume_unique=False, invert=False)     [source] 计算test ...

  5. python 中arange函数_Python numpy.arange函数方法的使用

    numpy.arange numpy.arange([start, ]stop, [step, ]dtype=None) 返回给定间隔内的均匀间隔的值. 在半开间隔[start,stop)(换句话说, ...

  6. python的std函数_Python numpy.nanstd函数方法的使用

    numpy.nanstd numpy.nanstd(a, axis=None, dtype=None, out=None, ddof=0, keepdims= 忽略NaN时,计算沿指定轴的标准偏差. ...

  7. python中tile的用法_Python numpy.tile函数方法的使用

    numpy.tile numpy.tile(A, reps)      [source] 通过重复A代表次数来构造数组. 如果代表的长度为d,则结果的尺寸为max(d,A.ndim). 如果A.ndi ...

  8. python分位数函数_Python numpy.quantile函数方法的使用

    numpy.quantile numpy.quantile(a, q, axis=None, out=None, overwrite_input=False, interpolation='linea ...

  9. python transpose函数_Python Numpy.transpose函数可视化解释

    二维情况 例如以下代码: x = np.arange(4).reshape((2,2)) 输出: x = ([[0, 1], [2, 3]]) 对于二维的数组,np.transpose()即为将矩阵进 ...

最新文章

  1. 自动化测试框架cucumber_BDD测试框架之Cucumber使用入门
  2. idea 新建的java项目没发run_IDEA 如何创建一个普通的 Java 项目,及创建 Java 文件并运行...
  3. VTK修炼之道79:交互与拾取_单位拾取
  4. 请珍惜应届生的身份,这是你这辈子最大的一次优势,也是最后一次!
  5. 一样入职的应届生工资不一样_刘涛入职阿里:为什么阿里要招聘明星?明星入职和普通人一样吗...
  6. 设置隐藏文件的显示与隐藏方法
  7. Exceptionless 5.0.0本地Docker快速部署介绍
  8. 为什么说边缘计算的发展比5G更重要?
  9. 软件生命周期管理研讨会有感
  10. yum时报Error: rpmdb open failed解决方法
  11. DEDE获得顶级栏目名称
  12. ubuntu server设置时区和更新时间
  13. 几何深度深度学习的学习之路
  14. dao设计模式_DAO设计模式
  15. redis命令参考string---MSETNX
  16. Cocos Creator学习のTiledMap
  17. 锐捷交换机常用命令速查
  18. 全球及中国石油天然气开采行业产量情况及十四五开发战略规划报告2021年版
  19. 关于Google大陆手机号不能验证的问题
  20. 西工大noj(25,26)

热门文章

  1. Android AVD emulator模拟器获取root权限(4.1.2以下)
  2. 撤销还是注销,你分得清吗?
  3. 如何通过AI性格分析填补虚拟试用市场的空缺?
  4. 【Unity3D】unity-mono编译libmono.so成功
  5. 校园表白墙--用到的用例图和活动图汇总
  6. 没做判空,工作179天的我在转正前一天被辞退了!
  7. 完整的卸载Oracle 11g数据库
  8. C语言sizeof函数解析
  9. Adobe XD CC简体中文版起步计划 中国用户可免费使用
  10. c语言数组中元素的加减乘除,c语言中,取余运算符和加减乘除的运算顺序??...