~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: Aaron Bentley
  • Date: 2006-06-03 16:23:09 UTC
  • mfrom: (1736 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1738.
  • Revision ID: aaron.bentley@utoronto.ca-20060603162309-c975ca9ea9fea344
Merge from bzr.dev

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
90
93
        self.failIfExists('dir/file')
91
94
        self.failIfExists('dir')
92
95
 
 
96
    def test_file_kind(self):
 
97
        self.build_tree(['file', 'dir/'])
 
98
        self.assertEquals('file', osutils.file_kind('file'))
 
99
        self.assertEquals('directory', osutils.file_kind('dir/'))
 
100
        if osutils.has_symlinks():
 
101
            os.symlink('symlink', 'symlink')
 
102
            self.assertEquals('symlink', osutils.file_kind('symlink'))
 
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')
 
129
 
93
130
 
94
131
class TestSafeUnicode(TestCase):
95
132