~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: John Arbash Meinel
  • Date: 2006-05-30 04:33:35 UTC
  • mto: (1711.2.26 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1734.
  • Revision ID: john@arbash-meinel.com-20060530043335-2c754880fbbe2950
Add tests for fancy file types.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""Tests for the osutils wrapper.
18
18
"""
19
19
 
 
20
import errno
20
21
import os
 
22
import socket
 
23
import stat
21
24
import sys
22
25
 
23
26
import bzrlib
97
100
        if osutils.has_symlinks():
98
101
            os.symlink('symlink', 'symlink')
99
102
            self.assertEquals('symlink', osutils.file_kind('symlink'))
100
 
        #TODO: jam 20060527 Test nodes, sockets, fifos, etc
 
103
        
 
104
        # TODO: jam 20060529 Test a block device
 
105
        try:
 
106
            os.lstat('/dev/null')
 
107
        except OSError, e:
 
108
            if e.errno not in (errno.ENOENT,):
 
109
                raise
 
110
        else:
 
111
            self.assertEquals('chardev', osutils.file_kind('/dev/null'))
 
112
 
 
113
        mkfifo = getattr(os, 'mkfifo', None)
 
114
        if mkfifo:
 
115
            mkfifo('fifo')
 
116
            try:
 
117
                self.assertEquals('fifo', osutils.file_kind('fifo'))
 
118
            finally:
 
119
                os.remove('fifo')
 
120
 
 
121
        AF_UNIX = getattr(socket, 'AF_UNIX', None)
 
122
        if AF_UNIX:
 
123
            s = socket.socket(AF_UNIX)
 
124
            s.bind('socket')
 
125
            try:
 
126
                self.assertEquals('socket', osutils.file_kind('socket'))
 
127
            finally:
 
128
                os.remove('socket')
101
129
 
102
130
 
103
131
class TestSafeUnicode(TestCase):