Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_flaky_xdist_nodedown(
mock_xdist_node_workeroutput,
assign_workeroutput,
mock_xdist_error
):
flaky_xdist = FlakyXdist(PLUGIN)
node = Mock()
if assign_workeroutput:
node.workeroutput = mock_xdist_node_workeroutput
else:
delattr(node, 'workeroutput')
delattr(node, 'slaveoutput')
mock_stream = Mock(StringIO)
with patch.object(PLUGIN, '_stream', mock_stream):
flaky_xdist.pytest_testnodedown(node, mock_xdist_error)
if assign_workeroutput and 'flaky_report' in mock_xdist_node_workeroutput:
mock_stream.write.assert_called_once_with(
mock_xdist_node_workeroutput['flaky_report'],
)
else:
assert not mock_stream.write.called