init
This commit is contained in:
commit
f4c09d21fe
18 changed files with 443 additions and 0 deletions
15
example/inlines.py
Normal file
15
example/inlines.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
|
||||
from os.path import dirname, join
|
||||
import sys
|
||||
sys.path.append(join(dirname(dirname(__file__)), "src"))
|
||||
|
||||
from okipy import test
|
||||
|
||||
|
||||
def add(a, b):
|
||||
return a + b
|
||||
|
||||
|
||||
@test()
|
||||
def it_works(ctx):
|
||||
pass
|
73
example/tests.py
Executable file
73
example/tests.py
Executable file
|
@ -0,0 +1,73 @@
|
|||
#!/usr/bin/env -S python
|
||||
|
||||
from os.path import dirname, join
|
||||
import sys
|
||||
sys.path.append(join(dirname(dirname(__file__)), "src"))
|
||||
from okipy import Suite, Ctx
|
||||
|
||||
|
||||
def main():
|
||||
suite = Suite()
|
||||
|
||||
@suite.test()
|
||||
def adds_correctly(ctx: Ctx):
|
||||
assert 2 + 2 == 4
|
||||
|
||||
@suite.test()
|
||||
def adds_incorrectly(ctx: Ctx):
|
||||
print("this must work")
|
||||
assert 2 + 2 == 5
|
||||
|
||||
@suite.test()
|
||||
def it_doesnt_fail(ctx: Ctx):
|
||||
print("hope this doesnt fail ...")
|
||||
print("oh, this will fail", file=sys.stderr)
|
||||
raise Exception("Expected failure.")
|
||||
|
||||
@suite.test()
|
||||
def it_fails(ctx: Ctx):
|
||||
with ctx.assert_raises():
|
||||
raise Exception("Expected failure.")
|
||||
|
||||
suite.run(sys.argv[1:])
|
||||
|
||||
|
||||
if __name__ == "__main__": main()
|
||||
|
||||
|
||||
"""
|
||||
prints the following :
|
||||
|
||||
|
||||
Running 4 / 4 tests
|
||||
|
||||
Ok adds_correctly
|
||||
Err adds_incorrectly
|
||||
Err it_doesnt_fail
|
||||
Ok it_fails
|
||||
Failed 2 / 4 tests
|
||||
|
||||
Fail 1 adds_incorrectly
|
||||
Traceback (most recent call last):
|
||||
File "/media/hdd0/Projects/okipy/./src/okipy/lib.py", line 46, in run
|
||||
self.procedure(Ctx(self))
|
||||
File "/media/hdd0/Projects/okipy/./example/tests.py", line 19, in adds_incorrectly
|
||||
assert 2 + 2 == 5
|
||||
AssertionError
|
||||
Stdout 1 lines
|
||||
this must work
|
||||
|
||||
|
||||
Fail 2 it_doesnt_fail
|
||||
Traceback (most recent call last):
|
||||
File "/media/hdd0/Projects/okipy/./src/okipy/lib.py", line 46, in run
|
||||
self.procedure(Ctx(self))
|
||||
File "/media/hdd0/Projects/okipy/./example/tests.py", line 25, in it_doesnt_fail
|
||||
raise Exception("Expected failure.")
|
||||
Exception: Expected failure.
|
||||
Stdout 1 lines
|
||||
hope this doesnt fail ...
|
||||
Stderr 1 lines
|
||||
oh, this will fail
|
||||
|
||||
"""
|
Loading…
Add table
Add a link
Reference in a new issue