Completed
Push — master ( 8e4604...8f3e72 )
by Bjorn
48s
created

tests.test_skippy()   C

Complexity

Conditions 8

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 8
dl 0
loc 20
rs 6.6666
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)} == {'a', 'b'}
37
38
        assert {fname for _hex, fname in list_files(root, root, False)} == {'a', 'b'}
39
40
        assert [fname for _hex, fname in list_files(os.path.join(root, '.dotdir'), root)] == []
41
42
43
def test_dot_path():
44
    files = """
45
        - a:
46
            - .skipfile: |
47
                b/.c/d/e
48
            - b:
49
                - .c:
50
                    - d:
51
                        - e: |
52
                            hello
53
                        - f: |
54
                            world
55
            - g
56
    """
57
    print "test_dot_path"
58
    with create_files(files) as directory:
59
        os.chdir(directory)
60
        assert [fname for _hex, fname in list_files('a', directory)] == ['g']
61