|
10 | 10 |
|
11 | 11 | from pandas.io.clipboard import PyperclipException, clipboard_get, clipboard_set
|
12 | 12 |
|
13 |
| -try: |
14 |
| - DataFrame({"A": [1, 2]}).to_clipboard() |
15 |
| - _DEPS_INSTALLED = 1 |
16 |
| -except (PyperclipException, RuntimeError): |
17 |
| - _DEPS_INSTALLED = 0 |
18 |
| - |
19 | 13 |
|
20 | 14 | def build_kwargs(sep, excel):
|
21 | 15 | kwargs = {}
|
@@ -146,9 +140,17 @@ def test_mock_clipboard(mock_clipboard):
|
146 | 140 | assert result == "abc"
|
147 | 141 |
|
148 | 142 |
|
| 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 | + |
149 | 152 | @pytest.mark.single
|
150 | 153 | @pytest.mark.clipboard
|
151 |
| -@pytest.mark.skipif(not _DEPS_INSTALLED, reason="clipboard primitives not installed") |
152 | 154 | @pytest.mark.usefixtures("mock_clipboard")
|
153 | 155 | class TestClipboard:
|
154 | 156 | 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):
|
256 | 258 |
|
257 | 259 | @pytest.mark.single
|
258 | 260 | @pytest.mark.clipboard
|
259 |
| -@pytest.mark.skipif(not _DEPS_INSTALLED, reason="clipboard primitives not installed") |
260 | 261 | @pytest.mark.parametrize("data", ["\U0001f44d...", "Ωœ∑´...", "abcd..."])
|
| 262 | +@pytest.mark.usefixtures("check_clipboard") |
261 | 263 | def test_raw_roundtrip(data):
|
262 | 264 | # PR #25040 wide unicode wasn't copied correctly on PY3 on windows
|
263 | 265 | clipboard_set(data)
|
|
0 commit comments