Skip to content

Commit fdd6a5e

Browse files
datapythonistameeseeksmachine
authored andcommitted
Backport PR pandas-dev#29712: CI: Fix clipboard problems
1 parent b05b96e commit fdd6a5e

File tree

5 files changed

+20
-24
lines changed

5 files changed

+20
-24
lines changed

.travis.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ matrix:
2828

2929
include:
3030
- env:
31-
- JOB="3.8" ENV_FILE="ci/deps/travis-38.yaml" PATTERN="(not slow and not network)"
31+
- JOB="3.8" ENV_FILE="ci/deps/travis-38.yaml" PATTERN="(not slow and not network and not clipboard)"
3232

3333
- env:
34-
- JOB="3.7" ENV_FILE="ci/deps/travis-37.yaml" PATTERN="(not slow and not network)"
34+
- JOB="3.7" ENV_FILE="ci/deps/travis-37.yaml" PATTERN="(not slow and not network and not clipboard)"
3535

3636
- env:
37-
- JOB="3.6, locale" ENV_FILE="ci/deps/travis-36-locale.yaml" PATTERN="((not slow and not network) or (single and db))" LOCALE_OVERRIDE="zh_CN.UTF-8" SQL="1"
37+
- JOB="3.6, locale" ENV_FILE="ci/deps/travis-36-locale.yaml" PATTERN="((not slow and not network and not clipboard) or (single and db))" LOCALE_OVERRIDE="zh_CN.UTF-8" SQL="1"
3838
services:
3939
- mysql
4040
- postgresql
4141

4242
- env:
43-
- JOB="3.6, coverage" ENV_FILE="ci/deps/travis-36-cov.yaml" PATTERN="((not slow and not network) or (single and db))" PANDAS_TESTING_MODE="deprecate" COVERAGE=true SQL="1"
43+
- JOB="3.6, coverage" ENV_FILE="ci/deps/travis-36-cov.yaml" PATTERN="((not slow and not network and not clipboard) or (single and db))" PANDAS_TESTING_MODE="deprecate" COVERAGE=true SQL="1"
4444
services:
4545
- mysql
4646
- postgresql

ci/azure/posix.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
py36_minimum_versions:
1919
ENV_FILE: ci/deps/azure-36-minimum_versions.yaml
2020
CONDA_PY: "36"
21-
PATTERN: "not slow and not network"
21+
PATTERN: "not slow and not network and not clipboard"
2222

2323
py36_locale_slow_old_np:
2424
ENV_FILE: ci/deps/azure-36-locale_slow.yaml
@@ -36,12 +36,12 @@ jobs:
3636
PATTERN: "not slow and not network"
3737
LANG: "it_IT.utf8"
3838
LC_ALL: "it_IT.utf8"
39-
EXTRA_APT: "language-pack-it"
39+
EXTRA_APT: "language-pack-it xsel"
4040

4141
py36_32bit:
4242
ENV_FILE: ci/deps/azure-36-32bit.yaml
4343
CONDA_PY: "36"
44-
PATTERN: "not slow and not network"
44+
PATTERN: "not slow and not network and not clipboard"
4545
BITS32: "yes"
4646

4747
py37_locale:
@@ -50,7 +50,7 @@ jobs:
5050
PATTERN: "not slow and not network"
5151
LANG: "zh_CN.utf8"
5252
LC_ALL: "zh_CN.utf8"
53-
EXTRA_APT: "language-pack-zh-hans"
53+
EXTRA_APT: "language-pack-zh-hans xsel"
5454

5555
py37_np_dev:
5656
ENV_FILE: ci/deps/azure-37-numpydev.yaml

ci/run_tests.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ if [ "$COVERAGE" ]; then
1414
COVERAGE="-s --cov=pandas --cov-report=xml:$COVERAGE_FNAME"
1515
fi
1616

17-
PYTEST_CMD="pytest -m \"$PATTERN\" -n auto --dist=loadfile -s --strict --durations=10 --junitxml=test-data.xml $TEST_ARGS $COVERAGE pandas"
18-
19-
# Travis does not have have an X server
20-
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
21-
DISPLAY=DISPLAY=:99.0
22-
PYTEST_CMD="xvfb-run -e /dev/stdout $PYTEST_CMD"
17+
# If no X server is found, we use xvfb to emulate it
18+
if [[ $(uname) == "Linux" && -z $DISPLAY ]]; then
19+
export DISPLAY=":0"
20+
XVFB="xvfb-run "
2321
fi
2422

23+
PYTEST_CMD="${XVFB}pytest -m \"$PATTERN\" -n auto --dist=loadfile -s --strict --durations=10 --junitxml=test-data.xml $TEST_ARGS $COVERAGE pandas"
24+
2525
echo $PYTEST_CMD
2626
sh -c "$PYTEST_CMD"
2727

ci/setup_env.sh

+5
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ echo "remove postgres if has been installed with conda"
114114
echo "we use the one from the CI"
115115
conda remove postgresql -y --force || true
116116

117+
echo
118+
echo "remove qt"
119+
echo "causes problems with the clipboard, we use xsel for that"
120+
conda remove qt -y --force || true
121+
117122
echo
118123
echo "conda list pandas"
119124
conda list pandas

pandas/tests/io/test_clipboard.py

+1-10
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,7 @@
88
from pandas import DataFrame, get_option, read_clipboard
99
import pandas._testing as tm
1010

11-
from pandas.io.clipboard import PyperclipException, clipboard_get, clipboard_set
12-
13-
try:
14-
DataFrame({"A": [1, 2]}).to_clipboard()
15-
_DEPS_INSTALLED = 1
16-
except (PyperclipException, RuntimeError):
17-
_DEPS_INSTALLED = 0
11+
from pandas.io.clipboard import clipboard_get, clipboard_set
1812

1913

2014
def build_kwargs(sep, excel):
@@ -148,7 +142,6 @@ def test_mock_clipboard(mock_clipboard):
148142

149143
@pytest.mark.single
150144
@pytest.mark.clipboard
151-
@pytest.mark.skipif(not _DEPS_INSTALLED, reason="clipboard primitives not installed")
152145
@pytest.mark.usefixtures("mock_clipboard")
153146
class TestClipboard:
154147
def check_round_trip_frame(self, data, excel=None, sep=None, encoding=None):
@@ -256,9 +249,7 @@ def test_round_trip_valid_encodings(self, enc, df):
256249

257250
@pytest.mark.single
258251
@pytest.mark.clipboard
259-
@pytest.mark.skipif(not _DEPS_INSTALLED, reason="clipboard primitives not installed")
260252
@pytest.mark.parametrize("data", ["\U0001f44d...", "Ωœ∑´...", "abcd..."])
261-
@pytest.mark.xfail(reason="flaky in CI", strict=False)
262253
def test_raw_roundtrip(data):
263254
# PR #25040 wide unicode wasn't copied correctly on PY3 on windows
264255
clipboard_set(data)

0 commit comments

Comments
 (0)