Пример #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
Пример #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']
Пример #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) == []
Пример #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()
Пример #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)
Пример #6
0
def test_scan_empty(tmpdir):
    result = bigdir.scan(str(tmpdir))
    assert list(result) == []
Пример #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"]
Пример #8
0
def test_scan_too_many_args():
    with pytest.raises(TypeError):
        bigdir.scan(None, None)
Пример #9
0
def test_scan_noarg():
    with pytest.raises(TypeError):
        bigdir.scan()
Пример #10
0
def bigdir_0(path):
    bigdir.scan(path)
Пример #11
0
def bigdir_1(path):
    for p in bigdir.scan(path):
        break
Пример #12
0
def bigdir_all(path):
    for p in bigdir.scan(path):
        pass