Browse Source

Added a unit test for keyboard interrupt

pull/377/head
Loren Schlomer 5 years ago
parent
commit
8b9a0c521f
No known key found for this signature in database GPG Key ID: 82E6D9D4AA4CBB83
3 changed files with 20 additions and 1 deletions
  1. +3
    -0
      cli/lesspass/core.py
  2. +2
    -1
      cli/test-requirements.txt
  3. +15
    -0
      cli/tests/test_interaction.py

+ 3
- 0
cli/lesspass/core.py View File

@@ -52,3 +52,6 @@ def main(args=sys.argv[1:]):
print("-" * 80)
else:
print(generated_password)

if __name__ == '__main__':
main()

+ 2
- 1
cli/test-requirements.txt View File

@@ -1,4 +1,5 @@
tox
pytest
flake8
mock
mock
pexpect

+ 15
- 0
cli/tests/test_interaction.py View File

@@ -0,0 +1,15 @@
import unittest
import pexpect
import signal
import time

class TestInteraction(unittest.TestCase):
def test_keyboard_interrupt(self):

p = pexpect.spawn('/bin/bash -c "python lesspass/core.py --prompt"')
time.sleep(1)

p.kill(signal.SIGINT)
p.expect(pexpect.EOF)

self.assertEqual(p.before, b'Site: ')

Loading…
Cancel
Save