tests.utilities.strip()   A
last analyzed

Complexity

Conditions 3

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 7
nop 3
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
"""Test helpers."""
2
3
4
def strip(text, tabs=None, end='\n'):
5
    """Strip leading whitespace indentation on multiline string literals."""
6
    lines = []
7
8
    for line in text.strip().splitlines():
9
        if not tabs:
10
            tabs = line.count(' ' * 4)
11
        lines.append(line.replace(' ' * tabs * 4, '', 1))
12
13
    return '\n'.join(lines) + end
14