Skip to content

Commit

Permalink
Merge pull request #11 from Koheron/context
Browse files Browse the repository at this point in the history
Start context tests
  • Loading branch information
jeanminet authored Nov 25, 2016
2 parents ee8351d + bd2154e commit af4cb34
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ TMP = tmp
TEST_VENV = venv
PY2_VENV = $(TEST_VENV)/py2
PY3_VENV = $(TEST_VENV)/py3
TESTS_PY = koheron/test/tests.py koheron/test/exception_tests.py
TESTS_PY = koheron/test/tests.py koheron/test/exception_tests.py koheron/test/context_tests.py

PYPI_VERSION=$(shell curl -s 'https://pypi.python.org/pypi/koheron/json'| PYTHONIOENCODING=utf8 python -c "import sys, json; print json.load(sys.stdin)['info']['version']")
CURRENT_VERSION=$(shell python -c "from koheron.version import __version__; print(__version__)")
Expand Down
33 changes: 33 additions & 0 deletions koheron/test/context_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

import sys
import os
import pytest
import re

sys.path = [".."] + sys.path
from koheron import KoheronClient, command, __version__

class UsesContext:
def __init__(self, client):
self.client = client

@command()
def set_float_from_tests(self, f):
return self.client.recv_bool()

@command()
def is_myself(self):
return self.client.recv_bool()

port = int(os.getenv('PYTEST_PORT', '36000'))

client = KoheronClient('127.0.0.1', port)
uses_ctx = UsesContext(client)

@pytest.mark.parametrize('uses_ctx', [uses_ctx])
def test_set_float_from_tests(uses_ctx):
assert uses_ctx.set_float_from_tests(12.5)

@pytest.mark.parametrize('uses_ctx', [uses_ctx])
def test_is_myself(uses_ctx):
assert uses_ctx.is_myself()

0 comments on commit af4cb34

Please sign in to comment.