Esempio n. 1
0
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
Esempio n. 2
0
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']
Esempio n. 3
0
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) == []
Esempio n. 4
0
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()
Esempio n. 5
0
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)
Esempio n. 6
0
def test_scan_empty(tmpdir):
    result = bigdir.scan(str(tmpdir))
    assert list(result) == []
Esempio n. 7
0
def test_single_file(tmpdir):
    f = tmpdir.join("test.txt")
    f.write("Hello.")

    result = bigdir.scan(str(tmpdir))
    assert list(result) == ["test.txt"]
Esempio n. 8
0
def test_scan_too_many_args():
    with pytest.raises(TypeError):
        bigdir.scan(None, None)
Esempio n. 9
0
def test_scan_noarg():
    with pytest.raises(TypeError):
        bigdir.scan()
Esempio n. 10
0
def bigdir_0(path):
    bigdir.scan(path)
Esempio n. 11
0
def bigdir_1(path):
    for p in bigdir.scan(path):
        break
Esempio n. 12
0
def bigdir_all(path):
    for p in bigdir.scan(path):
        pass