/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: Wouter van Heyst
  • Date: 2006-06-06 12:06:20 UTC
  • mfrom: (1740 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1752.
  • Revision ID: larstiq@larstiq.dyndns.org-20060606120620-50066b0951e4ef7c
merge bzr.dev 1740

Show diffs side-by-side

added added

removed removed

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