Completed
Push — master ( 0065b3...42ed64 )
by Bjorn
53s
created

tests.test_listfiles()   A

Complexity

Conditions 2

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 2
dl 0
loc 2
rs 10
1
# -*- coding: utf-8 -*-
2
import os
3
4
from dkfileutils.listfiles import list_files, read_skipfile
5
from yamldirs import create_files
6
7
BASEDIR = os.path.dirname(__file__)
8
print "FILE:", __file__
9
print "BSDIR:", BASEDIR
10
print "cwd:", os.getcwd()
11
12
13
def _files(fit):
14
    return [y for x,y in fit]
15
16
17
def test_skipfile():
18
    assert read_skipfile('.', ['foo']) == ['foo']
19
20
21
def test_skippy():
22
    files = """
23
        - a
24
        - b
25
        - f:
26
            - .dotfile
27
        - __pycache__:
28
            - c
29
        - htmlcov:
30
            - d
31
        - e.pyc
32
        - foo.egg-info:
33
            - e
34
    """
35
    with create_files(files) as root:
36
        assert [fname for _hex, fname in list_files(root, root)] == [
37
            'a', 'b'
38
        ]
39
40
        assert [fname for _hex, fname in list_files(root, root, False)] == [
41
            'a', 'b'
42
        ]
43
44
        assert [fname for _hex, fname in list_files(os.path.join(root, '.dotdir'), root)] == []
45