~hudson-openstack/nova/trunk

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/twisted/internet/test/test_pollingfile.py

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2009 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_checkWorkUnicode(self):
 
24
        """
 
25
        When one tries to pass unicode to L{_pollingfile._PollableWritePipe}, a
 
26
        C{TypeError} is raised instead of passing the data to C{WriteFile}
 
27
        call which is going to mangle it.
 
28
        """
 
29
        p = _pollingfile._PollableWritePipe(1, lambda: None)
 
30
        p.write("test")
 
31
        p.checkWork()
 
32
 
 
33
        p.write(u"test")
 
34
        self.assertRaises(TypeError, p.checkWork)
 
35
 
 
36
 
 
37
 
 
38
if _pollingfile is None:
 
39
    TestPollableWritePipe.skip = "_pollingfile is only avalable under Windows."