https://github.com/jayin/python-tc
utils for common test
https://github.com/jayin/python-tc
Last synced: 6 months ago
JSON representation
utils for common test
- Host: GitHub
- URL: https://github.com/jayin/python-tc
- Owner: Jayin
- License: mit
- Created: 2014-03-30T04:04:11.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-08-05T01:04:38.000Z (over 11 years ago)
- Last Synced: 2025-02-07T09:12:46.602Z (11 months ago)
- Language: Python
- Size: 183 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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
```