Skip to content

Commit 427367b

Browse files
committed
more refactoring
1 parent 05d4f54 commit 427367b

File tree

1 file changed

+13
-30
lines changed

1 file changed

+13
-30
lines changed

ultraplot/tests/test_thread_safety.py

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -44,40 +44,23 @@ def wrapped_func(**kw):
4444
raise RuntimeError("Thread raised a warning")
4545

4646

47-
def test_setting_within_context():
47+
@pytest.mark.parametrize("with_context", [True, False])
48+
@pytest.mark.parametrize(
49+
"prop, options",
50+
[
51+
("font.size", list(range(10))),
52+
("abc", "A. a. aa aaa aaaa.".split()),
53+
],
54+
)
55+
def test_setting_without_context(prop, options, with_context):
4856
"""
4957
Test the thread safety of a context setting
5058
"""
51-
# We spawn workers and these workers should try to set
52-
# an arbitrarry rc parameter. This should
53-
# be local to that context and not affect the main thread.
54-
prop, value = "font.size", uplt.rc["font.size"]
55-
options = list(range(10))
56-
_spawn_and_run_threads(
57-
modify_rc_on_thread, prop=prop, options=options, with_context=True
58-
)
59-
assert uplt.rc[prop] == value
60-
61-
62-
def test_setting_without_context():
63-
"""
64-
Test the thread safety of a context setting
65-
"""
66-
# We spawn workers and these workers should try to set
67-
# an arbitrarry rc parameter. This should
68-
# be local to that context and not affect the main thread.
69-
#
70-
# Test an ultraplot parameter
71-
prop = "abc"
7259
value = uplt.rc[prop]
73-
options = "A. a. aa aaa aaaa.".split()
7460
_spawn_and_run_threads(
75-
modify_rc_on_thread, prop=prop, options=options, with_context=False
61+
modify_rc_on_thread,
62+
prop=prop,
63+
options=options,
64+
with_context=with_context,
7665
)
7766
assert uplt.rc[prop] == value
78-
79-
prop, value = "font.size", uplt.rc["font.size"]
80-
options = list(range(10))
81-
_spawn_and_run_threads(
82-
modify_rc_on_thread, prop=prop, options=options, with_context=False
83-
)

0 commit comments

Comments
 (0)