Completed
Push — develop ( 8db71b...72d992 )
by Jace
02:49
created

yorm.test.is_none()   A

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 2
rs 10
1
"""Unit tests for the `yorm` package."""
2
3
import os
4
import time
5
import logging
6
7
import expecter
8
9
10
def is_none(x):
11
    return x is None
12
13
14
def is_true(x):
15
    return x is True
16
17
18
def is_false(x):
19
    return x is False
20
21
22
def exists(x):
23
    return os.path.exists(x)
24
25
26
def missing(x):
27
    return not os.path.exists(x)
28
29
30
expecter.add_expectation(is_none)
31
expecter.add_expectation(is_true)
32
expecter.add_expectation(is_false)
33
expecter.add_expectation(exists)
34
expecter.add_expectation(missing)
35
36
37
def strip(text, tabs=None, end='\n'):
38
    """Strip leading whitespace indentation on multiline string literals."""
39
    lines = []
40
41
    for line in text.strip().splitlines():
42
        if not tabs:
43
            tabs = line.count(' ' * 4)
44
        lines.append(line.replace(' ' * tabs * 4, '', 1))
45
46
    return '\n'.join(lines) + end
47
48
49
def refresh_file_modification_times(seconds=1.1):
50
    """Sleep to allow file modification times to refresh."""
51
    logging.info("Delaying for %s second%s...", seconds,
52
                 "" if seconds == 1 else "s")
53
    time.sleep(seconds)
54