summaryrefslogtreecommitdiff
path: root/tests/functional/s/simplifiable/simplifiable_if_expression.py
blob: bcfdf890b8fffc8c46339a4e09e93506578a391b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""Test that some if expressions can be simplified."""

# pylint: disable=missing-docstring, invalid-name


def test_simplifiable_1(arg):
    # Simple test that can be replaced by bool(arg)
    return True if arg else False # [simplifiable-if-expression]

def test_simplifiable_2(arg):
    # Simple test that can be replaced by not arg
    return False if arg else True # [simplifiable-if-expression]

def test_simplifiable_3(arg):
    # Simple test that can be replaced by arg == 1
    return True if arg == 1 else False # [simplifiable-if-expression]

def test_simplifiable_4(arg):
    # Simple test that can be replaced by not (arg == 1)
    return False if arg == 1 else True # [simplifiable-if-expression]

def test_not_simplifiable(arg):
    x = True if arg else True
    y = 0 if arg else 1
    t = False if arg != 1 else False
    t2 = None if arg > 3 else False
    return x, y, t, t2