Tox, pytest and pyperclip - System doesn't find clipboard

Alexandre Paloschi Horta alexandre.horta at gmail.com
Sun Jun 19 22:17:09 EDT 2016


Hi everyone.

I'm having the following problem on an app I'm developing.

I'm writing a software that uses the Pyperclip module. I'm using pytest for the tests. Everything worked well so far, as long as I run the tests via pytest.

The thing is, I want to use Tox, and now things didn't work so well. When I run the tests via Tox, the following error happens on those tests that depend on pyperclip:


self = <pyperclip.clipboards.init_no_clipboard.<locals>.ClipboardUnavailable object at 0xb6a2246c>
args = ('Small sample of text in the clipboard.',), kwargs = {}

    def __call__(self, *args, **kwargs):
>       raise PyperclipException(EXCEPT_MSG)
E       pyperclip.exceptions.PyperclipException: 
E           Pyperclip could not find a copy/paste mechanism for your system.
E           For more information, please visit https://pyperclip.readthedocs.org


On Linux, the pyperclip module depends on the existence of a way to access the copy/paste mechanism. Either one of those works: xclip, xsel, GTK or PyQT4. I noticed that on my machine pyperclip is using xclip, so I tried these configurations on tox.ini:

[testenv]
deps =
    py
    pytest
    pyperclip
    pluggy
commands = 
    py.test -vv
whitelist_externals = /usr/bin/xclip


[testenv]
deps =
    py
    pytest
    pyperclip
    pluggy
commands = 
    py.test -vv
    /usr/bin/xclip
whitelist_externals = /usr/bin/xclip


[testenv]
deps =
    py
    pytest
    pyperclip
    pluggy
commands = 
    py.test -vv

[testenv:Linux]
whitelist_externals = /usr/bin/xclip

None worked. What am I doing wrong?

Here are the software versions:
pyperclip 1.5.27
pytest 2.9.1
python 3.4.2
Debian with Gnome


More information about the Python-list mailing list