示例#1
0
文件: test_bigdir.py 项目: OEP/bigdir
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
文件: test_bigdir.py 项目: OEP/bigdir
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
文件: test_bigdir.py 项目: OEP/bigdir
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
文件: test_bigdir.py 项目: OEP/bigdir
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
文件: test_bigdir.py 项目: OEP/bigdir
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
文件: test_bigdir.py 项目: OEP/bigdir
def test_scan_empty(tmpdir):
    result = bigdir.scan(str(tmpdir))
    assert list(result) == []
示例#7
0
文件: test_bigdir.py 项目: OEP/bigdir
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
文件: test_bigdir.py 项目: OEP/bigdir
def test_scan_too_many_args():
    with pytest.raises(TypeError):
        bigdir.scan(None, None)
示例#9
0
文件: test_bigdir.py 项目: OEP/bigdir
def test_scan_noarg():
    with pytest.raises(TypeError):
        bigdir.scan()
示例#10
0
文件: benchmark.py 项目: OEP/bigdir
def bigdir_0(path):
    bigdir.scan(path)
示例#11
0
文件: benchmark.py 项目: OEP/bigdir
def bigdir_1(path):
    for p in bigdir.scan(path):
        break
示例#12
0
文件: benchmark.py 项目: OEP/bigdir
def bigdir_all(path):
    for p in bigdir.scan(path):
        pass