Skip to content
Snippets Groups Projects
Commit 3b36b636 authored by gpotter2's avatar gpotter2 Committed by gpotter2
Browse files

Fix mock_windows tests

parent ecda1d9e
No related branches found
No related tags found
No related merge requests found
...@@ -15,7 +15,7 @@ install: ...@@ -15,7 +15,7 @@ install:
- choco install -y npcap wireshark - choco install -y npcap wireshark
- ps: .\.appveyor\InstallWindump.ps1 - ps: .\.appveyor\InstallWindump.ps1
# Install Python modules # 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%" - set PATH="%PYTHON%\\Scripts\\;%PATH%"
test_script: test_script:
......
...@@ -82,21 +82,6 @@ import sys ...@@ -82,21 +82,6 @@ import sys
import mock import mock
import readline 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 index = 0
@mock.patch("pyreadline.console.console.Console.size") @mock.patch("pyreadline.console.console.Console.size")
...@@ -114,12 +99,8 @@ def emulate_main_input(data, mock_readfunc, mock_pyr_size): ...@@ -114,12 +99,8 @@ def emulate_main_input(data, mock_readfunc, mock_pyr_size):
r_data = data[index] r_data = data[index]
if r_data.startswith("#AUTOCOMPLETE"): if r_data.startswith("#AUTOCOMPLETE"):
send_text = re.match(r'#AUTOCOMPLETE{(.*)}', r_data).group(1) send_text = re.match(r'#AUTOCOMPLETE{(.*)}', r_data).group(1)
stopFlag = Event() cmpl = readline.rl.get_completer()
thread = sendTextAndTab(stopFlag, send_text) r_data = cmpl(send_text, 0)
thread.start()
# This will block the program until the thread has pushed the stuff
r_data = readline.rl.readline()
stopFlag.set()
index +=1 index +=1
print r_data print r_data
return r_data return r_data
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment