pytest断言编写器

asserted的Python项目详细描述


#断言
[![特拉维斯状态](https://travis-ci.org/hellowol/asserted.svg?branch=master)(https://travis ci.org/hellowol/asserted)
[![COV](https://codecov.io/gh/hellowoll/asserted/branch/master/graph/badge.svg)(https://codecov.io/gh/hellowoll/asserted/branch/master)
[![Github发布](https://img.shields.io/github/tag/hellowrol/asserted.svg?label=github+release)(https://github.com/hellowrol/asserted/releases)
[![pypi版本](https://badge.fury.io/py/asserted.svg)](https://pypi.python.org/pypi/asserted/)


asserted是一个简单的工具,它可以为传递给它的对象编写pytest。
这不是完美的方法,您仍然需要处理导入,如果您需要检查所有属性是否正确,可以使用fixtures。

写入测试。

--test_prefix test prefix
-sp save_path,--save_path save_path
savepath
-sm,--separate_methods
separate methods to there own test functions.
-st,--sort_iterables
separate methods to there own test functions测试函数。
-q禁用日志记录。
```

````````
={}
self.is_int=1
self.is_float=0.5
self.is_generator_expression=(i代表范围(2)中的i)
self.is_datetime=datetime.datetime(1970,1,1)

@property
def props(self):
"comment"
返回"props"

def method(self):
返回"method"

异步def async metod(self):
返回"async metod"

异步def async metod 2(self):
返回"async metod 2"

@类方法'a戋classmethod'

@staticmethod
def a戋staticmethod():
返回'a戋staticmethod'

@asyncio.coroutine
def a戋coro戋u with戋return(self):
返回'a戋coro戋u with戋return'

def a戋generator戋u function(self):
yield i

def a_missing_arg(self,arg):
return arg
`````````

````````
assert_write(asserted.example_class.ex(),write_full_tests=true,separate_methods=true,sort_iterables=true)
将创建下面的代码。
`````

```````
def test_ex():
ex=asserted.example_class.ex()
assert ex.att1="att1"
assert ex.data="data"
assert str(ex.is_datetime.date())="1970-01-01"
assert排序(例如is_dict.items())==[('a','a'),('b','b')]
断言ex.is_false is false
断言ex.is_float==0.5
断言排序(列表(例如is_generator_expression))==[0,1]
断言ex.is_int==1
断言排序(例如is_list)=[1,2,3,4,5]
断言ex.is_true是真的
断言排序(例如是元组)=[1,2,3]
assert ex.props="props"

def test_ex_classmethod():
ex=断言。example_class.ex()
assert ex.a_classmethod()="a_classmethod"

def test_ex_coro_with_return():
ex=断言。example_class.ex()

async def gogo():
a_coro_with_return=等待ex.a_coro_with_return()
断言a_coro_with_return=="a_coro_with_return"
异步获取事件循环(2)运行直到完成(gogo())


def test_ex_generator_function():
ex=asserted.example_class.ex()
assert sorted(list(ex.a_generator_function()))==[0,1,2]

ex=asserted.example_class.ex()
assert ex.a_staticmethod=="一个静态方法"

ex=断言。示例_class.ex()

async_metod=等待ex.async_metod()
assert async_metod=="async_metod"
asyncio.get_event_loop()。运行_直到完成(gogo())


def测试异步方法2():
ex=断言。示例2.ex()

async def gogo():
async方法2=等待示例2.async方法2()
assert async方法2="async方法2"
asyncio.get事件循环()。运行直到完成(gogo())

deftest_ex_method():
ex=断言。example_class.ex()
assert ex.method()="method"


def test_ex_missing_a_arg():
ex=断言。example_class.ex()
assert ex.missing_a_arg()="missing_arg"

````

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java当我点击MainActivity中的按钮以显示其他活动时,它不起作用   java游戏!框架:在请求之间获取控制器的组件/字段/对象   JavaBlackBerry:调用计算器并检索值?   java Struts2 jQuery插件提交按钮   java无法将更新的画布绘制到活动   java如何将Gson值放入HashMap   使用截取时出现java错误:RecyclerView:未连接适配器;跳过布局   java组织。冬眠HibernateException:在Hibernate搜索中编制索引时出错(在事务完成之前)   java Swagger服务器存根生成工作流   java JInternalFrame底部阴影问题   java nio缓冲区类中limit()的用法是什么   java水平回收器视图内部选项卡布局   java Maven无法找到依赖项   java如何管理不同应用程序实例的权限文件?