Starting with macOS 10.11, the OS has a limitation about the clipboard usage: it's not possible to call CFPasteboardCreate when there is no pasteboard, i.e. when the computer is on the loginwindow.
This is bad because we cannot test the "Copy-share link" context menu entry. The test is there, in test_context_menu.py, but disabled for macOS.
We need to a way to have access to the clipboard, even (most importantly) from the CI.
FTR, this is the current code (that works well outside the CI):
@staticmethod def cb_copy(text: str) -> None: """Copy some *text* into the clipboard. Emulate: echo "blablabla" | pbcopy w """ with subprocess.Popen(["pbcopy", "w"], stdin=subprocess.PIPE) as p: p.stdin.write(text.encode("utf-8")) p.stdin.close() p.wait() @staticmethod def cb_paste() -> str: data = subprocess.check_output(["pbpaste", "r"]) return data.decode("utf-8")
I used this code too, that works outside the CI (but I prefer to keep the previous code and not use the PyObjC module, it is less readable):
@staticmethod def cb_copy(text: str) -> None: from AppKit import NSPasteboard, NSStringPboardType from Foundation import NSString, NSUTF8StringEncoding pb = NSPasteboard.generalPasteboard() pb.declareTypes_owner_([NSStringPboardType], None) newStr = NSString.stringWithString_(text) newData = newStr.nsstring().dataUsingEncoding_(NSUTF8StringEncoding) pb.setData_forType_(newData, NSStringPboardType) @staticmethod def cb_paste() -> str: from AppKit import NSPasteboard, NSStringPboardType pb = NSPasteboard.generalPasteboard() return pb.stringForType_(NSStringPboardType)
This code suffers from the same issue.
- is related to
-
NXDRIVE-2071 Use GitHub Actions to run functional tests
- Resolved
-
NXDRIVE-2387 Migrate some old functional tests to functional
- Open