Skip to content
Snippets Groups Projects
Verified Commit 9696d549 authored by David Beniamine's avatar David Beniamine
Browse files

Add tests

parent 6b7e351d
No related branches found
No related tags found
No related merge requests found
Pipeline #110 passed
*.sw?
.egg*
.ropeproject
.pytest*
*.egg-info
__pycache__
image: python:3.6
stages:
- build
- test
- deploy
before_script:
- pip install setuptools
- pip install .
pytest:
stage: test
script: python setup.py test
...@@ -74,7 +74,8 @@ setup( ...@@ -74,7 +74,8 @@ setup(
Suppose you want to run a `doStuf` function that takes exactly one argument : Suppose you want to run a `doStuf` function that takes exactly one argument :
```python ```python
runner = safeRunner() from pySafeRunner import safeRunner
runner = safeRunner.safeRunner()
for i in range(0,5): for i in range(0,5):
runner.run(doStuff, i) runner.run(doStuff, i)
``` ```
...@@ -86,7 +87,6 @@ for i in range(0,5): ...@@ -86,7 +87,6 @@ for i in range(0,5):
Suppose you want to run a `doStuf` function that takes exactly two arguments : Suppose you want to run a `doStuf` function that takes exactly two arguments :
```python ```python
runner = safeRunner()
for i in range(0,5): for i in range(0,5):
for i in range(5,10): for i in range(5,10):
runner.run(doStuff, (i,j)) runner.run(doStuff, (i,j))
...@@ -97,7 +97,6 @@ for i in range(0,5): ...@@ -97,7 +97,6 @@ for i in range(0,5):
Suppose you want to run a `doStuf` function that takes 3 named arguments : Suppose you want to run a `doStuf` function that takes 3 named arguments :
```python ```python
runner = safeRunner()
for i in range(0,5): for i in range(0,5):
for i in range(5,10): for i in range(5,10):
runner.run(doStuff, {'i':i,'k':5,'j':j}) runner.run(doStuff, {'i':i,'k':5,'j':j})
......
File moved
from pySafeRunner import safeRunner
def compute(i,j=5, k=0):
from random import randint
print("i {}, j {}, k {}".format(i,j,k))
if randint(0,10) >= 9:
raise Exception("Huge fail")
else:
return i*j+k
def test_kwargs():
runner = safeRunner.safeRunner()
for i in range(0,5):
for j in range(5,10):
print(runner.run(compute, {'i':i,'k':5,'j':j}))
def test_packedargs():
runner = safeRunner.safeRunner()
for i in range(0,5):
for j in range(5,10):
print(runner.run(compute, (i,j,5)))
def test_singleArg():
runner = safeRunner.safeRunner()
for i in range(0,5):
for j in range(5,10):
print(runner.run(compute, i))
def test_singlemap():
runner = safeRunner.safeRunner()
for res in runner.map(compute, range(0,5)):
print(res)
def test_doublemap():
runner = safeRunner.safeRunner()
for res in runner.map(compute, range(0,5),range(5,10)):
print(res)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment