Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Lib/test/test_fcntl.py

    r2 r391  
    44
    55"""
    6 import fcntl
    76import os
    87import struct
    98import sys
     9import _testcapi
    1010import unittest
    11 from test.test_support import verbose, TESTFN, unlink, run_unittest
     11from test.test_support import (verbose, TESTFN, unlink, run_unittest,
     12    import_module)
     13
     14# Skip test if no fcntl module.
     15fcntl = import_module('fcntl')
     16
    1217
    1318# TODO - Write tests for flock() and lockf().
     
    2429            start_len = "qq"
    2530
    26     if sys.platform in ('netbsd1', 'netbsd2', 'netbsd3',
    27                         'Darwin1.2', 'darwin',
    28                         'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5',
    29                         'freebsd6', 'freebsd7', 'freebsd8',
    30                         'bsdos2', 'bsdos3', 'bsdos4',
    31                         'openbsd', 'openbsd2', 'openbsd3', 'openbsd4'):
     31    if (sys.platform.startswith(('netbsd', 'freebsd', 'openbsd', 'bsdos'))
     32        or sys.platform == 'darwin'):
    3233        if struct.calcsize('l') == 8:
    3334            off_t = 'l'
     
    8283        self.f.close()
    8384
     85    def test_fcntl_bad_file(self):
     86        class F:
     87            def __init__(self, fn):
     88                self.fn = fn
     89            def fileno(self):
     90                return self.fn
     91        self.assertRaises(ValueError, fcntl.fcntl, -1, fcntl.F_SETFL, os.O_NONBLOCK)
     92        self.assertRaises(ValueError, fcntl.fcntl, F(-1), fcntl.F_SETFL, os.O_NONBLOCK)
     93        self.assertRaises(TypeError, fcntl.fcntl, 'spam', fcntl.F_SETFL, os.O_NONBLOCK)
     94        self.assertRaises(TypeError, fcntl.fcntl, F('spam'), fcntl.F_SETFL, os.O_NONBLOCK)
     95        # Issue 15989
     96        self.assertRaises(ValueError, fcntl.fcntl, _testcapi.INT_MAX + 1,
     97                                                   fcntl.F_SETFL, os.O_NONBLOCK)
     98        self.assertRaises(ValueError, fcntl.fcntl, F(_testcapi.INT_MAX + 1),
     99                                                   fcntl.F_SETFL, os.O_NONBLOCK)
     100        self.assertRaises(ValueError, fcntl.fcntl, _testcapi.INT_MIN - 1,
     101                                                   fcntl.F_SETFL, os.O_NONBLOCK)
     102        self.assertRaises(ValueError, fcntl.fcntl, F(_testcapi.INT_MIN - 1),
     103                                                   fcntl.F_SETFL, os.O_NONBLOCK)
     104
    84105    def test_fcntl_64_bit(self):
    85106        # Issue #1309352: fcntl shouldn't fail when the third arg fits in a
     
    90111            flags = fcntl.DN_MULTISHOT
    91112        except AttributeError:
    92             # F_NOTIFY or DN_MULTISHOT unavailable, skipping
    93             return
     113            self.skipTest("F_NOTIFY or DN_MULTISHOT unavailable")
    94114        fd = os.open(os.path.dirname(os.path.abspath(TESTFN)), os.O_RDONLY)
    95115        try:
Note: See TracChangeset for help on using the changeset viewer.