File: windows_test.py

package info (click to toggle)
python-tornado 5.1.1-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,292 kB
  • sloc: python: 28,599; sh: 105; ansic: 65; xml: 49; makefile: 48; sql: 23
file content (25 lines) | stat: -rw-r--r-- 739 bytes parent folder | download
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
from __future__ import absolute_import, division, print_function
import functools
import os
import socket
import unittest

from tornado.platform.auto import set_close_exec

skipIfNonWindows = unittest.skipIf(os.name != 'nt', 'non-windows platform')


@skipIfNonWindows
class WindowsTest(unittest.TestCase):
    def test_set_close_exec(self):
        # set_close_exec works with sockets.
        s = socket.socket()
        self.addCleanup(s.close)
        set_close_exec(s.fileno())

        # But it doesn't work with pipes.
        r, w = os.pipe()
        self.addCleanup(functools.partial(os.close, r))
        self.addCleanup(functools.partial(os.close, w))
        with self.assertRaises(WindowsError):
            set_close_exec(r)