Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jayin/python-tc

utils for common test
https://github.com/jayin/python-tc

Last synced: 10 days ago
JSON representation

utils for common test

Awesome Lists containing this project

README

        

Python-TC
=====================

utils for common test

Example
========
```python
#coding:utf-8
from tc import TC

def task():
for x in range(1,200000,2):
pass

#basic
with TC() as test:
task()

#custom:
class T(TC):
def __init__(self):
super(T,self).__init__()

def __enter__(self):
super(T,self).__enter__()
return self

def __exit__(self, exc_type, exc_val, exc_tb):
print('another test:')
super(T,self).__exit__(exc_type, exc_val, exc_tb)

print
with T() as t:
task()
```

output:
```shell
Time-consuming: 3.000021 ms

another test:
Time-consuming: 3.000021 ms
```

use decorator
===
make it more sexy:
```python

@Test
def work():
for x in range(1,200000,2):
pass

work()
```

output:
```shell
Time-consuming: 3.999949 ms
```