Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try pytest-xdist and pytest-rerunfailures #229

Closed
wants to merge 8 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
run with xdist and adapt tests
mscheltienne committed Mar 14, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 56b50b17da8fcebc602ad8486fb7a8330ee99ee6
14 changes: 10 additions & 4 deletions mne_lsl/lsl/tests/test_stream_info.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import uuid
from time import strftime

import numpy as np
@@ -164,7 +165,7 @@ def test_stream_info_equality():

def test_stream_info_representation():
"""Test the str() representation of an Info."""
sinfo = StreamInfo("pytest", "eeg", 3, 101, "float32", strftime("%H%M%S"))
sinfo = StreamInfo("pytest", "eeg", 3, 101, "float32", uuid.uuid4().hex[:6])
repr_ = str(sinfo)
assert "'pytest'" in repr_
assert "eeg" in repr_
@@ -175,7 +176,7 @@ def test_stream_info_representation():

def test_stream_info_properties(close_io):
"""Test properties."""
sinfo = StreamInfo("pytest", "eeg", 3, 101, "float32", strftime("%H%M%S"))
sinfo = StreamInfo("pytest", "eeg", 3, 101, "float32", uuid.uuid4().hex[:6])
assert isinstance(sinfo.created_at, float)
assert sinfo.created_at == 0.0
assert isinstance(sinfo.hostname, str)
@@ -226,7 +227,7 @@ def test_invalid_stream_info():
def test_stream_info_desc_from_info(close_io):
"""Test filling a description from an Info object."""
info = create_info(5, 1000, "eeg")
sinfo = StreamInfo("test", "eeg", 5, 1000, np.float32, strftime("%H%M%S"))
sinfo = StreamInfo("test", "eeg", 5, 1000, np.float32, uuid.uuid4().hex[:6])
sinfo.set_channel_info(info)
info_retrieved = sinfo.get_channel_info()
compare_infos(info, info_retrieved)
@@ -235,7 +236,12 @@ def test_stream_info_desc_from_info(close_io):
fname = testing.data_path() / "sample_audvis_raw.fif"
raw = read_raw_fif(fname, preload=False)
sinfo = StreamInfo(
"test", "", len(raw.ch_names), raw.info["sfreq"], np.float32, strftime("%H%M%S")
"test",
"",
len(raw.ch_names),
raw.info["sfreq"],
np.float32,
uuid.uuid4().hex[:6],
)
sinfo.set_channel_info(raw.info)
info_retrieved = sinfo.get_channel_info()
6 changes: 2 additions & 4 deletions mne_lsl/lsl/tests/test_stream_outlet.py
Original file line number Diff line number Diff line change
@@ -26,8 +26,7 @@ def test_push_numerical_sample(dtype_str, dtype, close_io):
x = np.array([1, 2], dtype=dtype)
assert x.shape == (2,) and x.dtype == dtype
# create stream descriptions
source_id = uuid.uuid4().hex[:6]
sinfo = StreamInfo("test", "", 2, 0.0, dtype_str, source_id)
sinfo = StreamInfo("test", "", 2, 0.0, dtype_str, uuid.uuid4().hex[:6])
outlet = StreamOutlet(sinfo, chunk_size=1)
_test_properties(outlet, dtype_str, 2, "test", 0.0, "")
inlet = StreamInlet(sinfo)
@@ -47,8 +46,7 @@ def test_push_str_sample(close_io):
"""Test push_sample with strings."""
x = ["1", "2"]
# create stream descriptions
source_id = uuid.uuid4().hex[:6]
sinfo = StreamInfo("test", "", 2, 0.0, "string", source_id)
sinfo = StreamInfo("test", "", 2, 0.0, "string", uuid.uuid4().hex[:6])
outlet = StreamOutlet(sinfo, chunk_size=1)
_test_properties(outlet, "string", 2, "test", 0.0, "")
inlet = StreamInlet(sinfo)
4 changes: 2 additions & 2 deletions mne_lsl/player/tests/test_player_lsl.py
Original file line number Diff line number Diff line change
@@ -21,8 +21,8 @@
def _create_inlet(name: str) -> StreamInlet:
"""Create an inlet to the open-stream."""
streams = resolve_streams()
streams = [stream for stream in streams if stream.name == name]
assert len(streams) == 1
assert streams[0].name == name
inlet = StreamInlet(streams[0])
inlet.open_stream(timeout=10)
return inlet
@@ -355,7 +355,7 @@ def test_player_annotations(raw_annotations, close_io):
assert data.size != 0
assert ts.size == data.shape[0]
# compare with a Stream object for simplicity
stream = Stream(bufsize=40, stype="annotations")
stream = Stream(bufsize=40, name=f"{name}-annotations", stype="annotations")
stream.connect(processing_flags=["clocksync"])
assert stream.info["ch_names"] == annotations
assert stream.get_channel_types() == ["misc"] * sinfo.n_channels
12 changes: 10 additions & 2 deletions mne_lsl/stream/tests/test_stream_lsl.py
Original file line number Diff line number Diff line change
@@ -175,7 +175,7 @@ def test_stream_invalid():

def test_stream_connection_no_args(mock_lsl_stream):
"""Test connection to the only available stream."""
stream = Stream(bufsize=2)
stream = Stream(bufsize=2, name=mock_lsl_stream.name)
assert stream._info is None
assert not stream.connected
assert stream.name is None
@@ -659,7 +659,15 @@ def test_stream_irregularly_sampled(close_io):

def test_stream_annotations_picks(mock_lsl_stream_annotations):
"""Test sub-selection of annotations."""
stream = Stream(bufsize=5, stype="annotations").connect().pick("test1")
stream = (
Stream(
bufsize=5,
name=f"{mock_lsl_stream_annotations.name}-annotations",
stype="annotations",
)
.connect()
.pick("test1")
)
time.sleep(5) # acquire data
data, ts = stream.get_data()
assert np.count_nonzero(data) == data.size
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -170,7 +170,7 @@ match = '^(?!setup|__init__|test_).*\.py'
match-dir = '^mne_lsl.*'

[tool.pytest.ini_options]
addopts = '--durations=20 --junit-xml=junit-results.xml -ra -v --cov-report= --tb=short --color=yes'
addopts = '--durations=20 --junit-xml=junit-results.xml -ra -v --cov-report= --tb=short --color=yes -n logical --dist worksteal'
junit_family = 'xunit2'
minversion = '8.0'