diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-06-28 23:06:02 -0400 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-06-28 23:06:02 -0400 |
commit | ddf812495b5fbd5296efb3741f51e70e97943100 (patch) | |
tree | cddf77d0b1053e6d30bdff447a94a865463815ef /tests/test_cmd2.py | |
parent | f60cf3fc866a3d8c466c29268c3a6c76967ea784 (diff) | |
download | cmd2-git-ddf812495b5fbd5296efb3741f51e70e97943100.tar.gz |
Improved unit test for writing to the pastebuffer/clipboard
It now uses cmd2.get_paste_buffer() to read the pastebuffer/clipboard instead of using Tkinter.
It now also tests appending to the pastebuffer/clipboard in addition to writing to it.
Diffstat (limited to 'tests/test_cmd2.py')
-rw-r--r-- | tests/test_cmd2.py | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 5ca95275..8394bd9f 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -416,27 +416,20 @@ def test_pipe_to_shell(base_app): def test_send_to_paste_buffer(base_app): from cmd2 import can_clip + # Test writing to the PasteBuffer/Clipboard run_cmd(base_app, 'help >') expected = normalize(BASE_HELP) # If the tools for interacting with the clipboard/pastebuffer are available if cmd2.can_clip: # Read from the clipboard - try: - # Python2 - import Tkinter as tk - except ImportError: - # Python3 - import tkinter as tk + assert normalize(cmd2.get_paste_buffer()) == expected - root = tk.Tk() - # keep the window from showing - root.withdraw() - - # read the clipboard - c = root.clipboard_get() - - assert normalize(c) == expected + # Test appending to the PasteBuffer/Clipboard + run_cmd(base_app, 'help history >>') + expected = normalize(BASE_HELP + '\n' + HELP_HISTORY) + if cmd2.can_clip: + assert normalize(cmd2.get_paste_buffer()) == expected def test_base_timing(base_app, capsys): |