From 3b36b636b65bba85e84ceb00aa8fe876a3b14a2b Mon Sep 17 00:00:00 2001
From: gpotter2 <gabriel@potter.fr>
Date: Mon, 27 Feb 2017 20:20:02 +0100
Subject: [PATCH] Fix mock_windows tests

---
 appveyor.yml          |  2 +-
 test/mock_windows.uts | 23 ++---------------------
 2 files changed, 3 insertions(+), 22 deletions(-)

diff --git a/appveyor.yml b/appveyor.yml
index b837dd5b..81705c9b 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -15,7 +15,7 @@ install:
   - choco install -y npcap wireshark
   - ps: .\.appveyor\InstallWindump.ps1
   # Install Python modules
-  - "%PYTHON%\\python -m pip install cryptography coverage mock pyreadline keyboard"
+  - "%PYTHON%\\python -m pip install cryptography coverage mock pyreadline"
   - set PATH="%PYTHON%\\Scripts\\;%PATH%"
 
 test_script:
diff --git a/test/mock_windows.uts b/test/mock_windows.uts
index 01f644b0..67b6e3ff 100644
--- a/test/mock_windows.uts
+++ b/test/mock_windows.uts
@@ -82,21 +82,6 @@ import sys
 
 import mock
 import readline
-from threading import Thread, Event
-
-class sendTextAndTab(Thread):
-    """Send text directly as Input"""
-    def __init__(self, event, text):
-        Thread.__init__(self)
-        self.stopped = event
-        self.send_text = text
-    def run(self):
-        import keyboard
-        time.sleep(1)
-        while not self.stopped.wait(0.5):
-            keyboard.write(self.send_text)
-            keyboard.send("tab")
-            keyboard.send("enter")
 
 index = 0
 @mock.patch("pyreadline.console.console.Console.size")
@@ -114,12 +99,8 @@ def emulate_main_input(data, mock_readfunc, mock_pyr_size):
             r_data = data[index]
             if r_data.startswith("#AUTOCOMPLETE"):
                 send_text = re.match(r'#AUTOCOMPLETE{(.*)}', r_data).group(1)
-                stopFlag = Event()
-                thread = sendTextAndTab(stopFlag, send_text)
-                thread.start()
-                # This will block the program until the thread has pushed the stuff
-                r_data = readline.rl.readline()
-                stopFlag.set()
+                cmpl = readline.rl.get_completer()
+                r_data = cmpl(send_text, 0)
         index +=1
         print r_data
         return r_data
-- 
GitLab