Skip to content

Commit 6557e9b

Browse files
committed
lazy check
1 parent ed9ae5f commit 6557e9b

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

pandas/tests/io/test_clipboard.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@
1010

1111
from pandas.io.clipboard import PyperclipException, clipboard_get, clipboard_set
1212

13-
try:
14-
DataFrame({"A": [1, 2]}).to_clipboard()
15-
_DEPS_INSTALLED = 1
16-
except (PyperclipException, RuntimeError):
17-
_DEPS_INSTALLED = 0
18-
1913

2014
def build_kwargs(sep, excel):
2115
kwargs = {}
@@ -146,9 +140,17 @@ def test_mock_clipboard(mock_clipboard):
146140
assert result == "abc"
147141

148142

143+
@pytest.fixture(scope="module")
144+
def check_clipboard():
145+
"""Check if we have a clipboard, skipping if it's not present"""
146+
try:
147+
DataFrame({"A": [1, 2]}).to_clipboard()
148+
except (PyperclipException, RuntimeError):
149+
pytest.skip("Missing clipboard dependency")
150+
151+
149152
@pytest.mark.single
150153
@pytest.mark.clipboard
151-
@pytest.mark.skipif(not _DEPS_INSTALLED, reason="clipboard primitives not installed")
152154
@pytest.mark.usefixtures("mock_clipboard")
153155
class TestClipboard:
154156
def check_round_trip_frame(self, data, excel=None, sep=None, encoding=None):
@@ -256,8 +258,8 @@ def test_round_trip_valid_encodings(self, enc, df):
256258

257259
@pytest.mark.single
258260
@pytest.mark.clipboard
259-
@pytest.mark.skipif(not _DEPS_INSTALLED, reason="clipboard primitives not installed")
260261
@pytest.mark.parametrize("data", ["\U0001f44d...", "Ωœ∑´...", "abcd..."])
262+
@pytest.mark.usefixtures("check_clipboard")
261263
def test_raw_roundtrip(data):
262264
# PR #25040 wide unicode wasn't copied correctly on PY3 on windows
263265
clipboard_set(data)

0 commit comments

Comments
 (0)