Test clipext

This commit is contained in:
Ethan Dalool 2017-04-07 17:43:53 -07:00
parent 46d66a15f4
commit eeba64f3f0
2 changed files with 56 additions and 3 deletions

View file

@ -5,15 +5,12 @@ INPUT_STRINGS = ['!i', '!in', '!input', '!stdin']
EOF = '\x1a'
def _input_lines():
userinput = []
while True:
try:
additional = input()
except EOFError:
# If you enter nothing but ctrl-z
additional = EOF
else:
userinput.append(additional)
additional = additional.split(EOF)
has_eof = len(additional) > 1

56
Clipext/test_clipext.py Normal file
View file

@ -0,0 +1,56 @@
import random
import string
import time
import clipext
paragraph = '''
There once was a man from Peru
Who dreamed he was eating his shoe
He woke with a fright
In the middle of the night
To find that his dream had come true.
'''.strip()
inputs_mocked = 0
def mock_input():
global inputs_mocked
s = ''.join(random.choice(string.ascii_lowercase) for x in range(10))
if inputs_mocked == 4:
s += clipext.EOF
inputs_mocked = 0
inputs_mocked += 1
return s
def mock_paste():
lines = [''.join(random.choice(string.digits) for x in range(10)) for x in range(4)]
lines = '\n'.join(lines)
return lines
clipext.pyperclip.paste = mock_paste
clipext.input = mock_input
def test_splitted(text):
print(repr(text))
print('=')
lines = clipext.resolve(text, split_lines=True)
print(list(lines))
print()
def test_unsplitted(text):
print(repr(text))
print('=')
text = clipext.resolve(text, split_lines=False)
print(repr(text))
print()
test_splitted(paragraph)
test_splitted('!c')
test_splitted('!i')
print()
test_unsplitted(paragraph)
test_unsplitted('!c')
test_unsplitted('!i')