Back to index

python3.2  3.2.2
Public Member Functions | Static Public Attributes
test.test_os.FileTests Class Reference

List of all members.

Public Member Functions

def setUp
def test_access
def test_closerange
def test_rename
def test_read
def test_write
def write_windows_console
def test_write_windows_console
def fdopen_helper
def test_fdopen

Static Public Attributes

 tearDown = setUp

Detailed Description

Definition at line 31 of file test_os.py.


Member Function Documentation

def test.test_os.FileTests.fdopen_helper (   self,
  args 
)

Definition at line 112 of file test_os.py.

00112 
00113     def fdopen_helper(self, *args):
00114         fd = os.open(support.TESTFN, os.O_RDONLY)
00115         f = os.fdopen(fd, *args)
00116         f.close()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 32 of file test_os.py.

00032 
00033     def setUp(self):
00034         if os.path.exists(support.TESTFN):
            os.unlink(support.TESTFN)

Here is the caller graph for this function:

Definition at line 37 of file test_os.py.

00037 
00038     def test_access(self):
00039         f = os.open(support.TESTFN, os.O_CREAT|os.O_RDWR)
00040         os.close(f)
00041         self.assertTrue(os.access(support.TESTFN, os.W_OK))

Here is the call graph for this function:

Definition at line 42 of file test_os.py.

00042 
00043     def test_closerange(self):
00044         first = os.open(support.TESTFN, os.O_CREAT|os.O_RDWR)
00045         # We must allocate two consecutive file descriptors, otherwise
00046         # it will mess up other file descriptors (perhaps even the three
00047         # standard ones).
00048         second = os.dup(first)
00049         try:
00050             retries = 0
00051             while second != first + 1:
00052                 os.close(first)
00053                 retries += 1
00054                 if retries > 10:
00055                     # XXX test skipped
00056                     self.skipTest("couldn't allocate two consecutive fds")
00057                 first, second = second, os.dup(second)
00058         finally:
00059             os.close(second)
00060         # close a fd that is open, and one that isn't
00061         os.closerange(first, first + 2)
00062         self.assertRaises(OSError, os.write, first, b"a")

Here is the call graph for this function:

Definition at line 117 of file test_os.py.

00117 
00118     def test_fdopen(self):
00119         fd = os.open(support.TESTFN, os.O_CREAT|os.O_RDWR)
00120         os.close(fd)
00121 
00122         self.fdopen_helper()
00123         self.fdopen_helper('r')
00124         self.fdopen_helper('r', 100)
00125 
00126 
# Test attributes on return values from os.*stat* family.

Here is the call graph for this function:

Definition at line 71 of file test_os.py.

00071 
00072     def test_read(self):
00073         with open(support.TESTFN, "w+b") as fobj:
00074             fobj.write(b"spam")
00075             fobj.flush()
00076             fd = fobj.fileno()
00077             os.lseek(fd, 0, 0)
00078             s = os.read(fd, 4)
00079             self.assertEqual(type(s), bytes)
00080             self.assertEqual(s, b"spam")

Here is the call graph for this function:

Definition at line 64 of file test_os.py.

00064 
00065     def test_rename(self):
00066         path = support.TESTFN
00067         old = sys.getrefcount(path)
00068         self.assertRaises(TypeError, os.rename, path, 0)
00069         new = sys.getrefcount(path)
00070         self.assertEqual(old, new)

Here is the call graph for this function:

Definition at line 81 of file test_os.py.

00081 
00082     def test_write(self):
00083         # os.write() accepts bytes- and buffer-like objects but not strings
00084         fd = os.open(support.TESTFN, os.O_CREAT | os.O_WRONLY)
00085         self.assertRaises(TypeError, os.write, fd, "beans")
00086         os.write(fd, b"bacon\n")
00087         os.write(fd, bytearray(b"eggs\n"))
00088         os.write(fd, memoryview(b"spam\n"))
00089         os.close(fd)
00090         with open(support.TESTFN, "rb") as fobj:
00091             self.assertEqual(fobj.read().splitlines(),
00092                 [b"bacon", b"eggs", b"spam"])

Here is the call graph for this function:

Definition at line 103 of file test_os.py.

00103 
00104     def test_write_windows_console(self):
00105         # Issue #11395: the Windows console returns an error (12: not enough
00106         # space error) on writing into stdout if stdout mode is binary and the
00107         # length is greater than 66,000 bytes (or less, depending on heap
00108         # usage).
00109         code = "print('x' * 100000)"
00110         self.write_windows_console(sys.executable, "-c", code)
00111         self.write_windows_console(sys.executable, "-u", "-c", code)

Here is the call graph for this function:

Definition at line 93 of file test_os.py.

00093 
00094     def write_windows_console(self, *args):
00095         retcode = subprocess.call(args,
00096             # use a new console to not flood the test output
00097             creationflags=subprocess.CREATE_NEW_CONSOLE,
00098             # use a shell to hide the console window (SW_HIDE)
00099             shell=True)
00100         self.assertEqual(retcode, 0)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 35 of file test_os.py.


The documentation for this class was generated from the following file: