QInstrument 2.3.2__tar.gz → 2.4.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. {qinstrument-2.3.2 → qinstrument-2.4.1}/PKG-INFO +1 -1
  2. {qinstrument-2.3.2 → qinstrument-2.4.1}/QInstrument.egg-info/PKG-INFO +1 -1
  3. {qinstrument-2.3.2 → qinstrument-2.4.1}/lib/QInstrumentWorker.py +8 -0
  4. {qinstrument-2.3.2 → qinstrument-2.4.1}/lib/QSerialInstrument.py +0 -8
  5. {qinstrument-2.3.2 → qinstrument-2.4.1}/lib/QSerialInterface.py +32 -10
  6. {qinstrument-2.3.2 → qinstrument-2.4.1}/pyproject.toml +1 -1
  7. {qinstrument-2.3.2 → qinstrument-2.4.1}/tests/test_QInstrumentWorker.py +2 -0
  8. {qinstrument-2.3.2 → qinstrument-2.4.1}/tests/test_QSR830Worker.py +2 -0
  9. {qinstrument-2.3.2 → qinstrument-2.4.1}/tests/test_QSerialInterface.py +20 -27
  10. {qinstrument-2.3.2 → qinstrument-2.4.1}/LICENSE.md +0 -0
  11. {qinstrument-2.3.2 → qinstrument-2.4.1}/QInstrument.egg-info/SOURCES.txt +0 -0
  12. {qinstrument-2.3.2 → qinstrument-2.4.1}/QInstrument.egg-info/dependency_links.txt +0 -0
  13. {qinstrument-2.3.2 → qinstrument-2.4.1}/QInstrument.egg-info/entry_points.txt +0 -0
  14. {qinstrument-2.3.2 → qinstrument-2.4.1}/QInstrument.egg-info/requires.txt +0 -0
  15. {qinstrument-2.3.2 → qinstrument-2.4.1}/QInstrument.egg-info/top_level.txt +0 -0
  16. {qinstrument-2.3.2 → qinstrument-2.4.1}/QInstrumentRack.py +0 -0
  17. {qinstrument-2.3.2 → qinstrument-2.4.1}/README.md +0 -0
  18. {qinstrument-2.3.2 → qinstrument-2.4.1}/__init__.py +0 -0
  19. {qinstrument-2.3.2 → qinstrument-2.4.1}/__main__.py +0 -0
  20. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/IPGPhotonics/IPGLaser/IPGLaserWidget.ui +0 -0
  21. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/IPGPhotonics/IPGLaser/__init__.py +0 -0
  22. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/IPGPhotonics/IPGLaser/fake.py +0 -0
  23. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/IPGPhotonics/IPGLaser/instrument.py +0 -0
  24. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/IPGPhotonics/IPGLaser/tree.py +0 -0
  25. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/IPGPhotonics/IPGLaser/widget.py +0 -0
  26. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/IPGPhotonics/__init__.py +0 -0
  27. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/Novanta/Opus/OpusWidget.ui +0 -0
  28. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/Novanta/Opus/__init__.py +0 -0
  29. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/Novanta/Opus/fake.py +0 -0
  30. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/Novanta/Opus/instrument.py +0 -0
  31. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/Novanta/Opus/tree.py +0 -0
  32. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/Novanta/Opus/widget.py +0 -0
  33. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/Novanta/Opus1064/__init__.py +0 -0
  34. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/Novanta/Opus1064/fake.py +0 -0
  35. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/Novanta/Opus1064/instrument.py +0 -0
  36. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/Novanta/Opus1064/tree.py +0 -0
  37. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/Novanta/Opus1064/widget.py +0 -0
  38. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/Novanta/Opus532/__init__.py +0 -0
  39. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/Novanta/Opus532/fake.py +0 -0
  40. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/Novanta/Opus532/instrument.py +0 -0
  41. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/Novanta/Opus532/tree.py +0 -0
  42. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/Novanta/Opus532/widget.py +0 -0
  43. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/Novanta/Opus660/__init__.py +0 -0
  44. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/Novanta/Opus660/fake.py +0 -0
  45. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/Novanta/Opus660/instrument.py +0 -0
  46. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/Novanta/Opus660/tree.py +0 -0
  47. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/Novanta/Opus660/widget.py +0 -0
  48. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/Novanta/__init__.py +0 -0
  49. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/PiezoDrive/PDUS210/PDUS210Widget.ui +0 -0
  50. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/PiezoDrive/PDUS210/__init__.py +0 -0
  51. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/PiezoDrive/PDUS210/fake.py +0 -0
  52. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/PiezoDrive/PDUS210/instrument.py +0 -0
  53. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/PiezoDrive/PDUS210/tree.py +0 -0
  54. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/PiezoDrive/PDUS210/widget.py +0 -0
  55. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/PiezoDrive/__init__.py +0 -0
  56. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/PriorScientific/Proscan/ProscanWidget.ui +0 -0
  57. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/PriorScientific/Proscan/__init__.py +0 -0
  58. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/PriorScientific/Proscan/fake.py +0 -0
  59. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/PriorScientific/Proscan/instrument.py +0 -0
  60. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/PriorScientific/Proscan/tree.py +0 -0
  61. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/PriorScientific/Proscan/widget.py +0 -0
  62. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/PriorScientific/__init__.py +0 -0
  63. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/StanfordResearch/DS345/DS345Widget.ui +0 -0
  64. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/StanfordResearch/DS345/__init__.py +0 -0
  65. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/StanfordResearch/DS345/fake.py +0 -0
  66. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/StanfordResearch/DS345/instrument.py +0 -0
  67. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/StanfordResearch/DS345/tree.py +0 -0
  68. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/StanfordResearch/DS345/widget.py +0 -0
  69. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/StanfordResearch/SR830/SR830Widget.ui +0 -0
  70. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/StanfordResearch/SR830/__init__.py +0 -0
  71. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/StanfordResearch/SR830/fake.py +0 -0
  72. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/StanfordResearch/SR830/instrument.py +0 -0
  73. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/StanfordResearch/SR830/tree.py +0 -0
  74. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/StanfordResearch/SR830/widget.py +0 -0
  75. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/StanfordResearch/SR830/worker.py +0 -0
  76. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/StanfordResearch/SR844/SR844Widget.ui +0 -0
  77. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/StanfordResearch/SR844/__init__.py +0 -0
  78. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/StanfordResearch/SR844/fake.py +0 -0
  79. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/StanfordResearch/SR844/instrument.py +0 -0
  80. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/StanfordResearch/SR844/tree.py +0 -0
  81. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/StanfordResearch/SR844/widget.py +0 -0
  82. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/StanfordResearch/SR844/worker.py +0 -0
  83. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/StanfordResearch/__init__.py +0 -0
  84. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/Tektronix/TDS1000/__init__.py +0 -0
  85. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/Tektronix/TDS1000/instrument.py +0 -0
  86. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/Tektronix/__init__.py +0 -0
  87. {qinstrument-2.3.2 → qinstrument-2.4.1}/instruments/__init__.py +0 -0
  88. {qinstrument-2.3.2 → qinstrument-2.4.1}/lib/Configure.py +0 -0
  89. {qinstrument-2.3.2 → qinstrument-2.4.1}/lib/QAbstractInstrument.py +0 -0
  90. {qinstrument-2.3.2 → qinstrument-2.4.1}/lib/QFakeInstrument.py +0 -0
  91. {qinstrument-2.3.2 → qinstrument-2.4.1}/lib/QInstrumentTree.py +0 -0
  92. {qinstrument-2.3.2 → qinstrument-2.4.1}/lib/QInstrumentWidget.py +0 -0
  93. {qinstrument-2.3.2 → qinstrument-2.4.1}/lib/QReconcileDialog.py +0 -0
  94. {qinstrument-2.3.2 → qinstrument-2.4.1}/lib/__init__.py +0 -0
  95. {qinstrument-2.3.2 → qinstrument-2.4.1}/lib/lazy.py +0 -0
  96. {qinstrument-2.3.2 → qinstrument-2.4.1}/setup.cfg +0 -0
  97. {qinstrument-2.3.2 → qinstrument-2.4.1}/tests/test_Configure.py +0 -0
  98. {qinstrument-2.3.2 → qinstrument-2.4.1}/tests/test_QAbstractInstrument.py +0 -0
  99. {qinstrument-2.3.2 → qinstrument-2.4.1}/tests/test_QDS345.py +0 -0
  100. {qinstrument-2.3.2 → qinstrument-2.4.1}/tests/test_QFakeInstrument.py +0 -0
  101. {qinstrument-2.3.2 → qinstrument-2.4.1}/tests/test_QIPGLaser.py +0 -0
  102. {qinstrument-2.3.2 → qinstrument-2.4.1}/tests/test_QInstrumentRack.py +0 -0
  103. {qinstrument-2.3.2 → qinstrument-2.4.1}/tests/test_QInstrumentWidget.py +0 -0
  104. {qinstrument-2.3.2 → qinstrument-2.4.1}/tests/test_QLedWidget.py +0 -0
  105. {qinstrument-2.3.2 → qinstrument-2.4.1}/tests/test_QOpus.py +0 -0
  106. {qinstrument-2.3.2 → qinstrument-2.4.1}/tests/test_QPDUS210.py +0 -0
  107. {qinstrument-2.3.2 → qinstrument-2.4.1}/tests/test_QProscan.py +0 -0
  108. {qinstrument-2.3.2 → qinstrument-2.4.1}/tests/test_QRotaryEncoderSpinBox.py +0 -0
  109. {qinstrument-2.3.2 → qinstrument-2.4.1}/tests/test_QSR830.py +0 -0
  110. {qinstrument-2.3.2 → qinstrument-2.4.1}/tests/test_QSR844.py +0 -0
  111. {qinstrument-2.3.2 → qinstrument-2.4.1}/tests/test_QSerialInstrument.py +0 -0
  112. {qinstrument-2.3.2 → qinstrument-2.4.1}/widgets/QJoystick.py +0 -0
  113. {qinstrument-2.3.2 → qinstrument-2.4.1}/widgets/QJoystickPad.py +0 -0
  114. {qinstrument-2.3.2 → qinstrument-2.4.1}/widgets/QLedWidget.py +0 -0
  115. {qinstrument-2.3.2 → qinstrument-2.4.1}/widgets/QRotaryEncoder.py +0 -0
  116. {qinstrument-2.3.2 → qinstrument-2.4.1}/widgets/QRotaryEncoderSpinBox.py +0 -0
  117. {qinstrument-2.3.2 → qinstrument-2.4.1}/widgets/QRotaryEncoderSpinBox.ui +0 -0
  118. {qinstrument-2.3.2 → qinstrument-2.4.1}/widgets/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: QInstrument
3
- Version: 2.3.2
3
+ Version: 2.4.1
4
4
  Summary: Qt-based framework for controlling scientific instruments over serial ports
5
5
  Author-email: "David G. Grier" <david.grier@nyu.edu>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: QInstrument
3
- Version: 2.3.2
3
+ Version: 2.4.1
4
4
  Summary: Qt-based framework for controlling scientific instruments over serial ports
5
5
  Author-email: "David G. Grier" <david.grier@nyu.edu>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -1,6 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import logging
4
+ import warnings
4
5
  from qtpy import QtCore
5
6
 
6
7
  logger = logging.getLogger(__name__)
@@ -43,6 +44,13 @@ class QInstrumentWorker(QtCore.QObject):
43
44
  '''
44
45
 
45
46
  def __init__(self, instrument, parent=None) -> None:
47
+ warnings.warn(
48
+ 'QInstrumentWorker is deprecated and will be removed in a future '
49
+ 'release. QSerialInterface.receive() no longer blocks the event '
50
+ 'loop, so instrument polling does not require a worker thread.',
51
+ DeprecationWarning,
52
+ stacklevel=2
53
+ )
46
54
  super().__init__(parent)
47
55
  self._instrument = instrument
48
56
  self._thread = QtCore.QThread()
@@ -133,14 +133,6 @@ class QSerialInstrument(QAbstractInstrument):
133
133
  The instance itself, whether or not a device was found.
134
134
  Call :meth:`isOpen` to check the result.
135
135
  '''
136
- # TODO: On macOS, Qt emits "QSocketNotifier: current thread's event
137
- # dispatcher has already been destroyed" for each port tried here.
138
- # Root cause: QSerialPort's POSIX backend uses QSocketNotifier, which
139
- # requires a running event loop, but waitForReadyRead() uses select()
140
- # directly and tears down the macOS CF dispatcher context on return.
141
- # Fix: replace waitForReadyRead() in QSerialInterface.receive() with
142
- # a QEventLoop + QTimer approach so notifiers always have an active
143
- # dispatcher. Deferred due to re-entrancy considerations.
144
136
  for port in QSerialPortInfo.availablePorts():
145
137
  portName = port.portName()
146
138
  logger.debug(f'Trying {portName}')
@@ -193,9 +193,13 @@ class QSerialInterface(QSerialPort):
193
193
  '''Read from the serial interface until the end-of-line sequence.
194
194
 
195
195
  Reads available data into a buffer until :attr:`eol` is found or
196
- the read times out. The EOL bytes are stripped from the returned
196
+ the read times out. The EOL bytes are stripped from the returned
197
197
  value.
198
198
 
199
+ Waiting is performed via a local ``QEventLoop`` driven by
200
+ ``readyRead`` and a ``QTimer``, so the main event loop remains
201
+ alive during the wait and the GUI stays responsive.
202
+
199
203
  Parameters
200
204
  ----------
201
205
  eol : str | bytes | None
@@ -216,17 +220,26 @@ class QSerialInterface(QSerialPort):
216
220
  eol = eol.encode() if isinstance(eol, str) else eol
217
221
  else:
218
222
  eol = self.eol
223
+ loop = QtCore.QEventLoop()
224
+ timer = QtCore.QTimer()
225
+ timer.setSingleShot(True)
226
+ timer.timeout.connect(loop.quit)
227
+ self.readyRead.connect(loop.quit)
219
228
  buffer = b''
220
229
  while True:
221
- if (not self.bytesAvailable() and
222
- not self.waitForReadyRead(self.timeout)):
223
- logger.debug('Timeout waiting for response')
224
- break
230
+ if not self.bytesAvailable():
231
+ timer.start(self.timeout)
232
+ loop.exec()
233
+ timer.stop()
234
+ if not self.bytesAvailable():
235
+ logger.debug('Timeout waiting for response')
236
+ break
225
237
  buffer += bytes(self.readAll())
226
238
  if eol and eol in buffer:
227
239
  buffer = buffer[:buffer.index(eol)]
228
240
  break
229
- return buffer if raw else buffer.decode()
241
+ self.readyRead.disconnect(loop.quit)
242
+ return buffer if raw else buffer.decode('utf-8', errors='replace')
230
243
 
231
244
  def readn(self, n: int = 1) -> bytes:
232
245
  '''Receive exactly n bytes from the instrument.
@@ -245,13 +258,22 @@ class QSerialInterface(QSerialPort):
245
258
  if not self.isOpen():
246
259
  logger.warning('Cannot read data: device is not open.')
247
260
  return b''
261
+ loop = QtCore.QEventLoop()
262
+ timer = QtCore.QTimer()
263
+ timer.setSingleShot(True)
264
+ timer.timeout.connect(loop.quit)
265
+ self.readyRead.connect(loop.quit)
248
266
  buffer = b''
249
267
  while len(buffer) < n:
250
- if (not self.bytesAvailable() and
251
- not self.waitForReadyRead(self.timeout)):
252
- logger.warning('Timeout waiting for response')
253
- break
268
+ if not self.bytesAvailable():
269
+ timer.start(self.timeout)
270
+ loop.exec()
271
+ timer.stop()
272
+ if not self.bytesAvailable():
273
+ logger.warning('Timeout waiting for response')
274
+ break
254
275
  buffer += bytes(self.readAll())
276
+ self.readyRead.disconnect(loop.quit)
255
277
  return buffer[:n]
256
278
 
257
279
  def sendbreak(self, duration: int = 250) -> None:
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "QInstrument"
7
- version = "2.3.2"
7
+ version = "2.4.1"
8
8
  description = "Qt-based framework for controlling scientific instruments over serial ports"
9
9
  readme = "README.md"
10
10
  license = { file = "LICENSE.md" }
@@ -3,6 +3,8 @@ from qtpy import QtCore
3
3
  from lib.QFakeInstrument import QFakeInstrument
4
4
  from lib.QInstrumentWorker import QInstrumentWorker
5
5
 
6
+ pytestmark = pytest.mark.filterwarnings('ignore::DeprecationWarning')
7
+
6
8
 
7
9
  # ---------------------------------------------------------------------------
8
10
  # Helpers
@@ -3,6 +3,8 @@ from qtpy import QtCore
3
3
  from instruments.StanfordResearch.SR830.fake import QFakeSR830
4
4
  from instruments.StanfordResearch.SR830.worker import QSR830Worker
5
5
  from instruments.StanfordResearch.SR844.fake import QFakeSR844
6
+
7
+ pytestmark = pytest.mark.filterwarnings('ignore::DeprecationWarning')
6
8
  from instruments.StanfordResearch.SR844.worker import QSR844Worker
7
9
 
8
10
 
@@ -22,6 +22,12 @@ def iface_crlf(qtbot):
22
22
  return QSerialInterface(eol='\r\n')
23
23
 
24
24
 
25
+ @pytest.fixture
26
+ def iface_fast(qtbot):
27
+ '''QSerialInterface with 1 ms timeout for timeout tests.'''
28
+ return QSerialInterface(eol='\n', timeout=1)
29
+
30
+
25
31
  # ---------------------------------------------------------------------------
26
32
  # Initialization
27
33
  # ---------------------------------------------------------------------------
@@ -117,52 +123,42 @@ class TestReceive:
117
123
 
118
124
  @patch.object(QSerialInterface, 'bytesAvailable', return_value=True)
119
125
  @patch.object(QSerialInterface, 'readAll', return_value=b'HELLO\n')
120
- @patch.object(QSerialInterface, 'waitForReadyRead', return_value=True)
121
- def test_strips_eol(self, mock_wait, mock_read, mock_avail, iface):
126
+ def test_strips_eol(self, mock_read, mock_avail, iface):
122
127
  assert iface.receive() == 'HELLO'
123
128
 
124
129
  @patch.object(QSerialInterface, 'bytesAvailable', return_value=True)
125
130
  @patch.object(QSerialInterface, 'readAll', return_value=b'HELLO\r\n')
126
- @patch.object(QSerialInterface, 'waitForReadyRead', return_value=True)
127
- def test_multibyte_eol_stripped(
128
- self, mock_wait, mock_read, mock_avail, iface_crlf):
131
+ def test_multibyte_eol_stripped(self, mock_read, mock_avail, iface_crlf):
129
132
  assert iface_crlf.receive() == 'HELLO'
130
133
 
131
134
  @patch.object(QSerialInterface, 'bytesAvailable', return_value=True)
132
135
  @patch.object(QSerialInterface, 'readAll', return_value=b'HELLO\n')
133
- @patch.object(QSerialInterface, 'waitForReadyRead', return_value=True)
134
- def test_raw_returns_bytes(self, mock_wait, mock_read, mock_avail, iface):
136
+ def test_raw_returns_bytes(self, mock_read, mock_avail, iface):
135
137
  assert iface.receive(raw=True) == b'HELLO'
136
138
 
137
139
  @patch.object(QSerialInterface, 'bytesAvailable', return_value=False)
138
- @patch.object(QSerialInterface, 'waitForReadyRead', return_value=False)
139
- def test_timeout_returns_empty_string(self, mock_wait, mock_avail, iface):
140
- assert iface.receive() == ''
140
+ def test_timeout_returns_empty_string(self, mock_avail, iface_fast):
141
+ assert iface_fast.receive() == ''
141
142
 
142
143
  @patch.object(QSerialInterface, 'bytesAvailable', return_value=False)
143
- @patch.object(QSerialInterface, 'waitForReadyRead', return_value=False)
144
- def test_timeout_logs(self, mock_wait, mock_avail, iface, caplog):
144
+ def test_timeout_logs(self, mock_avail, iface_fast, caplog):
145
145
  with caplog.at_level(logging.DEBUG):
146
- iface.receive()
146
+ iface_fast.receive()
147
147
  assert 'Timeout' in caplog.text
148
148
 
149
149
  @patch.object(QSerialInterface, 'bytesAvailable', return_value=True)
150
150
  @patch.object(QSerialInterface, 'readAll', return_value=b'DATA\r')
151
- @patch.object(QSerialInterface, 'waitForReadyRead', return_value=True)
152
- def test_override_eol(self, mock_wait, mock_read, mock_avail, iface):
151
+ def test_override_eol(self, mock_read, mock_avail, iface):
153
152
  assert iface.receive(eol='\r') == 'DATA'
154
153
 
155
154
  @patch.object(QSerialInterface, 'bytesAvailable', return_value=True)
156
155
  @patch.object(QSerialInterface, 'readAll', return_value=b'DATA\r')
157
- @patch.object(QSerialInterface, 'waitForReadyRead', return_value=True)
158
- def test_override_eol_as_bytes(self, mock_wait, mock_read, mock_avail, iface):
156
+ def test_override_eol_as_bytes(self, mock_read, mock_avail, iface):
159
157
  assert iface.receive(eol=b'\r') == 'DATA'
160
158
 
161
159
  @patch.object(QSerialInterface, 'bytesAvailable', return_value=True)
162
160
  @patch.object(QSerialInterface, 'readAll', return_value=b'A\nB\nC')
163
- @patch.object(QSerialInterface, 'waitForReadyRead', return_value=True)
164
- def test_returns_up_to_first_eol(
165
- self, mock_wait, mock_read, mock_avail, iface):
161
+ def test_returns_up_to_first_eol(self, mock_read, mock_avail, iface):
166
162
  assert iface.receive() == 'A'
167
163
 
168
164
 
@@ -174,27 +170,24 @@ class TestReadn:
174
170
 
175
171
  @patch.object(QSerialInterface, 'isOpen', return_value=True)
176
172
  @patch.object(QSerialInterface, 'bytesAvailable', return_value=True)
177
- @patch.object(QSerialInterface, 'waitForReadyRead', return_value=True)
178
173
  @patch.object(QSerialInterface, 'readAll', return_value=b'ABCDE')
179
- def test_trims_to_n(self, mock_read, mock_wait, mock_avail, mock_open, iface):
174
+ def test_trims_to_n(self, mock_read, mock_avail, mock_open, iface):
180
175
  assert iface.readn(3) == b'ABC'
181
176
 
182
177
  @patch.object(QSerialInterface, 'isOpen', return_value=True)
183
178
  @patch.object(QSerialInterface, 'bytesAvailable', return_value=True)
184
- @patch.object(QSerialInterface, 'waitForReadyRead', return_value=True)
185
179
  @patch.object(QSerialInterface, 'readAll', return_value=b'AB')
186
- def test_exact_match(self, mock_read, mock_wait, mock_avail, mock_open, iface):
180
+ def test_exact_match(self, mock_read, mock_avail, mock_open, iface):
187
181
  assert iface.readn(2) == b'AB'
188
182
 
189
183
  @patch.object(QSerialInterface, 'isOpen', return_value=True)
190
184
  @patch.object(QSerialInterface, 'bytesAvailable',
191
185
  side_effect=[True, False, False])
192
- @patch.object(QSerialInterface, 'waitForReadyRead', return_value=False)
193
186
  @patch.object(QSerialInterface, 'readAll', return_value=b'AB')
194
187
  def test_timeout_returns_partial(
195
- self, mock_read, mock_wait, mock_avail, mock_open, iface, caplog):
188
+ self, mock_read, mock_avail, mock_open, iface_fast, caplog):
196
189
  with caplog.at_level(logging.WARNING):
197
- result = iface.readn(5)
190
+ result = iface_fast.readn(5)
198
191
  assert result == b'AB'
199
192
  assert 'Timeout' in caplog.text
200
193
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes