Пример #1
0
def okpy_main():
    """
Usage:
    okpy [options] file/directory

options:
    --details:  output detail traceback if error

anything else?
    try `okpy --help` or `okpy --love`

--------------------
Have a nice day  :-)"""
    if not G_OPTIONS.target:
        _hint('No input file or directory, are you kidding me? \n\n %s' % okpy_main.__doc__)
        sys.exit(1)

    if G_OPTIONS.love:
        _hint('No body love you :-P')
        sys.exit(1)

    _setup_tests(G_OPTIONS.target)
    # Only support the `details` options
    okpy.run(G_OPTIONS.details)
Пример #2
0
@okpy.test
def check_it_wrong():
    assert (1 - 2) > 0

@okpy.test
def check_it_no_name_but_doc():
    """
            this is a __doc__
    """
    a = outer_exception()

@okpy.test
def check_it_catch():
    assert okpy.catch(catcher_exception, G_ERROR_NUMBER) in (ZeroDivisionError,)

@okpy.benchmark(n=1000, timeout=1000)
def benchmark_is_ok():
    n = 0
    for x in xrange(100):
        n += x


@okpy.benchmark(n=1, timeout=1)
def benchmark_is_fail():
    import time
    time.sleep(3)


if __name__ == '__main__':
    okpy.run()
Пример #3
0
# -*- coding:utf8 -*-
import fixpath
import okpy

@okpy.test
def i_am_ok():
    assert 1 + 1 == 2


@okpy.benchmark(n=100, timeout=10000)
def i_am_lighting():
    s = 1 + 1


if __name__ == '__main__':
    okpy.run(True)