2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-25 19:28:26 +08:00

sync_struct test: test more cases, pep8 fix, remove print

This commit is contained in:
Yann Sionneau 2015-06-03 15:54:50 +02:00
parent b8bdce5bd1
commit b27254ba80

View File

@ -1,5 +1,6 @@
import unittest import unittest
import asyncio import asyncio
import numpy as np
from artiq.protocols import sync_struct from artiq.protocols import sync_struct
@ -9,8 +10,14 @@ test_port = 7777
@asyncio.coroutine @asyncio.coroutine
def write_test_data(test_dict): def write_test_data(test_dict):
test_values = [5, 2.1, None, True, False,
{"a": 5, 2: np.linspace(0, 10, 1)},
(4, 5), (10,), "ab\nx\"'"]
for i in range(10): for i in range(10):
test_dict[str(i)] = i test_dict[str(i)] = i
for key, value in enumerate(test_values):
test_dict[key] = value
test_dict[1.5] = 1.5
test_dict["Finished"] = True test_dict["Finished"] = True
@ -30,9 +37,8 @@ class SyncStructCase(unittest.TestCase):
return init return init
def notify(self, mod): def notify(self, mod):
print("mod: {}".format(mod))
if (mod["action"] == "init" and "Finished" in mod["struct"])\ if (mod["action"] == "init" and "Finished" in mod["struct"])\
or (mod["action"] == "setitem" and mod["key"] == "Finished"): or (mod["action"] == "setitem" and mod["key"] == "Finished"):
self.receiving_done.set() self.receiving_done.set()
def setUp(self): def setUp(self):