Initial import to Tizen
[profile/ivi/python-twisted.git] / twisted / internet / test / test_pollingfile.py
1 # Copyright (c) Twisted Matrix Laboratories.
2 # See LICENSE for details.
3
4 """
5 Tests for L{twisted.internet._pollingfile}.
6 """
7
8 from twisted.python.runtime import platform
9 from twisted.trial.unittest import TestCase
10
11 if platform.isWindows():
12     from twisted.internet import _pollingfile
13 else:
14     _pollingfile = None
15
16
17
18 class TestPollableWritePipe(TestCase):
19     """
20     Tests for L{_pollingfile._PollableWritePipe}.
21     """
22
23     def test_writeUnicode(self):
24         """
25         L{_pollingfile._PollableWritePipe.write} raises a C{TypeError} if an
26         attempt is made to append unicode data to the output buffer.
27         """
28         p = _pollingfile._PollableWritePipe(1, lambda: None)
29         self.assertRaises(TypeError, p.write, u"test")
30
31
32     def test_writeSequenceUnicode(self):
33         """
34         L{_pollingfile._PollableWritePipe.writeSequence} raises a C{TypeError}
35         if unicode data is part of the data sequence to be appended to the
36         output buffer.
37         """
38         p = _pollingfile._PollableWritePipe(1, lambda: None)
39         self.assertRaises(TypeError, p.writeSequence, [u"test"])
40         self.assertRaises(TypeError, p.writeSequence, (u"test", ))
41
42
43
44
45 if _pollingfile is None:
46     TestPollableWritePipe.skip = "Test will run only on Windows."