Completed
Push — master ( 2fcab0...ed35bb )
by Bjorn
01:54
created

tests._files()   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
46
47
def test_dot_path():
48
    files = """
49
        - a:
50
            - .skipfile: |
51
                b/.c/d/e
52
            - b:
53
                - .c:
54
                    - d:
55
                        - e: |
56
                            hello
57
                        - f: |
58
                            world
59
            - g
60
    """
61
    print "test_dot_path"
62
    with create_files(files) as directory:
63
        os.chdir(directory)
64
        assert [fname for _hex, fname in list_files('a', directory)] == ['g']
65