示例#1
0
    assert exp == obs


@pytest.mark.parametrize(
    "inp, exp",
    [
        (True, None),
        (False, None),
        (1, None),
        (None, None),
        ("throwback.log", "throwback.log"),
        pytest.param("/dev/null", "/dev/null", marks=skip_if_on_windows),
        pytest.param(
            "/dev/nonexistent_dev",
            "/dev/nonexistent_dev"
            if is_writable_file("/dev/nonexistent_dev") else None,
            marks=skip_if_on_windows,
        ),
    ],
)
def test_to_logfile_opt(inp, exp):
    obs = to_logfile_opt(inp)
    assert exp == obs


@pytest.mark.parametrize(
    "inp, exp",
    [
        (None, ""),
        ("", ""),
        ("throwback.log", "throwback.log"),
示例#2
0
文件: test_tools.py 项目: mitnk/xonsh
    assert exp == obs


@pytest.mark.parametrize(
    "inp, exp",
    [
        (True, None),
        (False, None),
        (1, None),
        (None, None),
        ("throwback.log", "throwback.log"),
        pytest.param("/dev/null", "/dev/null", marks=skip_if_on_windows),
        pytest.param(
            "/dev/nonexistent_dev",
            "/dev/nonexistent_dev"
            if is_writable_file("/dev/nonexistent_dev")
            else None,
            marks=skip_if_on_windows,
        ),
    ],
)
def test_to_logfile_opt(inp, exp):
    obs = to_logfile_opt(inp)
    assert exp == obs


@pytest.mark.parametrize(
    "inp, exp",
    [
        (None, ""),
        ("", ""),
示例#3
0
                                      (False, False), (42, False),
                                      ([1, 2, 3], False), ((1, 2), False),
                                      (("wrong", "parameter"), False),
                                      skip_if_on_windows(('/dev/null', True))])
def test_is_logfile_opt(inp, exp):
    obs = is_logfile_opt(inp)
    assert exp == obs


@pytest.mark.parametrize(
    'inp, exp', [(True, None), (False, None), (1, None), (None, None),
                 ('throwback.log', 'throwback.log'),
                 skip_if_on_windows(('/dev/null', '/dev/null')),
                 skip_if_on_windows(
                     ('/dev/nonexistent_dev', '/dev/nonexistent_dev'
                      if is_writable_file('/dev/nonexistent_dev') else None))])
def test_to_logfile_opt(inp, exp):
    obs = to_logfile_opt(inp)
    assert exp == obs


@pytest.mark.parametrize('inp, exp', [(None, ''), ('', ''),
                                      ('throwback.log', 'throwback.log'),
                                      ('/dev/null', '/dev/null')])
def test_logfile_opt_to_str(inp, exp):
    obs = logfile_opt_to_str(inp)
    assert exp == obs


@pytest.mark.parametrize('inp, exp', [
    ('20', (20.0, 'c')),
示例#4
0
    skip_if_on_windows(('/dev/null', True))
])
def test_is_logfile_opt(inp, exp):
    obs = is_logfile_opt(inp)
    assert exp == obs


@pytest.mark.parametrize('inp, exp', [
        (True, None),
        (False, None),
        (1, None),
        (None, None),
        ('throwback.log', 'throwback.log'),
        skip_if_on_windows(('/dev/null', '/dev/null')),
        skip_if_on_windows(('/dev/nonexistent_dev',
            '/dev/nonexistent_dev' if is_writable_file('/dev/nonexistent_dev') else None))
    ])
def test_to_logfile_opt(inp, exp):
    obs = to_logfile_opt(inp)
    assert exp == obs


@pytest.mark.parametrize('inp, exp', [
    (None, ''),
    ('', ''),
    ('throwback.log', 'throwback.log'),
    ('/dev/null', '/dev/null')
])
def test_logfile_opt_to_str(inp, exp):
    obs = logfile_opt_to_str(inp)
    assert exp == obs