-
Notifications
You must be signed in to change notification settings - Fork 447
/
control_test.py
executable file
·74 lines (60 loc) · 1.6 KB
/
control_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python3
# encoding: utf-8
"""
control.py
Created by Thomas Mangin on 2015-01-01.
Copyright (c) 2009-2015 Exa Networks. All rights reserved.
License: 3-clause BSD. (See the COPYRIGHT file)
"""
import time
import socket
import unittest
def speak(name, data):
time.sleep(0.005)
try:
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.connect(name)
sock.sendall(data)
except socket.error:
pass
class TestControl(unittest.TestCase):
def setUp(self):
pass
def test_failed_creation(self):
pass
# control = Control()
# try:
# result = control.init()
# self.assertFalse(result)
# except IOError:
# # could not write in the location
# pass
# finally:
# control.cleanup()
def validate(self, message, check):
pass
# name = tempfile.mktemp()
# control = Control(name,False)
# try:
# result = control.init()
# self.assertTrue(result)
#
# p = Process(target=speak, args=(name,message))
# p.start()
#
# string = control.loop()
# self.assertEqual(string, check)
# p.join()
# finally:
# control.cleanup()
# del control
def test_no_newline(self):
self.validate('x', '')
def test_one_newline(self):
self.validate('x\n', 'x')
def test_two_newline(self):
self.validate('-\nx\n', 'x')
def test_leftover(self):
self.validate('-\nx\n-', 'x')
if __name__ == '__main__':
unittest.main()