def test_scan_error_open(tmpdir): f = tmpdir.join("test.txt") f.write("Hello.") # open() fails while initializing iterator with pytest.raises(IOError) as e: bigdir.scan(str(f)) assert e.value.errno == errno.ENOTDIR
def test_unicode2(tmpdir): root = tmpdir.join(u'\u0108') root.mkdir() root.join('foo.txt').ensure() arg = six.text_type(root) result = list(bigdir.scan(arg)) assert result == ['foo.txt']
def test_scan_error_readdir(tmpdir): # readdir() file is removed root = tmpdir.join('foo').mkdir() iterator = bigdir.scan(str(root)) root.remove() # NOTE POSIX.1 says that this case should be treated like an EOF # glibc implements this, and that's what we're following assert list(iterator) == []
def test_remove_files(tmpdir): files = set(['apple', 'banana', 'carrot']) for filename in files: tmpdir.join(filename).ensure() for filename in bigdir.scan(str(tmpdir)): assert filename in files os.remove(os.path.join(str(tmpdir), filename)) files.remove(filename) assert files == set()
def test_unicode1(tmpdir): # Technical note: path1 and path2 are both legal ways of representing the # same perceptual data. If you read the data off of HFS it makes this # conversion. Kind of strange... path1 = u'\u0108.txt' path2 = u'C\u0302.txt' tmpdir.join(path1).ensure() result = list(bigdir.scan(str(tmpdir))) assert len(result) == 1 assert result[0] in (path1, path2)
def test_scan_empty(tmpdir): result = bigdir.scan(str(tmpdir)) assert list(result) == []
def test_single_file(tmpdir): f = tmpdir.join("test.txt") f.write("Hello.") result = bigdir.scan(str(tmpdir)) assert list(result) == ["test.txt"]
def test_scan_too_many_args(): with pytest.raises(TypeError): bigdir.scan(None, None)
def test_scan_noarg(): with pytest.raises(TypeError): bigdir.scan()
def bigdir_0(path): bigdir.scan(path)
def bigdir_1(path): for p in bigdir.scan(path): break
def bigdir_all(path): for p in bigdir.scan(path): pass