[test] add a conftest.py file with fixtures for prologix emulator setup in tests

Sun, 03 Jun 2018 18:09:47 +0200

author
David Douard <david.douard@logilab.fr>
date
Sun, 03 Jun 2018 18:09:47 +0200
changeset 106
bb477c9ea28d
parent 105
89123c2af2fd
child 107
ffd1559ad7f0

[test] add a conftest.py file with fixtures for prologix emulator setup in tests

pygpibtoolkit/test/conftest.py file | annotate | diff | comparison | revisions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pygpibtoolkit/test/conftest.py	Sun Jun 03 18:09:47 2018 +0200
@@ -0,0 +1,20 @@
+import serial
+import pygpibtoolkit.prologix_emulator as PE
+
+import pytest
+
+
+@pytest.fixture(scope='session')
+def newemulator():
+    emul = PE.PrologixEmulator()
+    cnx = serial.Serial(emul.serialurl, timeout=0)
+    yield (emul, cnx)
+    emul.close()
+    cnx.close()
+
+
+@pytest.fixture
+def emulator(newemulator):
+    emul, cnx = newemulator
+    emul.reset()
+    return emul, cnx

mercurial