Пример #1
0
def test_bv_already_bumped_default(basic, tmpdir, already_setup):
    """
    If 'version.py' is already bumped, don't update it
    """
    bf = pytest.basic_fx
    v = pytest.this['target']
    with tbx.chdir(tmpdir.strpath):
        pre = tbx.contents(v)
        with pytest.raises(SystemExit) as e:
            gitr.gitr_bv({'bv': True, '<path>': None})
        post = tbx.contents(v)
    assert bf['already'].format(v) in str(e)
    assert pre == post
Пример #2
0
def test_bv_already_staged_explicit(basic, tmpdir, already_setup):
    """
    If an explicit target is already staged, don't update it
    """
    bf = pytest.basic_fx
    v = pytest.this['target']
    with tbx.chdir(tmpdir.strpath):
        pre = tbx.contents(v)
        with pytest.raises(SystemExit) as e:
            gitr.gitr_bv({'bv': True, '<path>': v})
        post = tbx.contents(v)
    assert bf['already'].format(v) in str(e)
    assert pre == post
Пример #3
0
def test_bv_already_bumped_default(basic, tmpdir, already_setup):
    """
    If 'version.py' is already bumped, don't update it
    """
    bf = pytest.basic_fx
    v = pytest.this['target']
    with tbx.chdir(tmpdir.strpath):
        pre = tbx.contents(v)
        with pytest.raises(SystemExit) as e:
            gitr.gitr_bv({'bv': True, '<path>': None})
        post = tbx.contents(v)
    assert bf['already'].format(v) in str(e)
    assert pre == post
Пример #4
0
def test_bv_already_staged_explicit(basic, tmpdir, already_setup):
    """
    If an explicit target is already staged, don't update it
    """
    bf = pytest.basic_fx
    v = pytest.this['target']
    with tbx.chdir(tmpdir.strpath):
        pre = tbx.contents(v)
        with pytest.raises(SystemExit) as e:
            gitr.gitr_bv({'bv': True, '<path>': v})
        post = tbx.contents(v)
    assert bf['already'].format(v) in str(e)
    assert pre == post
Пример #5
0
def test_bv_already_bumped_deep2(basic, tmpdir, already_setup):
    """
    If 'version.py' is already bumped, don't update it
    """
    pytest.dbgfunc()
    bf = pytest.basic_fx
    v = tmpdir.join(pytest.this['target'])
    with tbx.chdir(v.dirname):
        pre = tbx.contents(v.basename)
        with pytest.raises(SystemExit) as e:
            gitr.gitr_bv({'bv': True, '<path>': None})
        post = tbx.contents(v.basename)
    assert bf['already'].format(pytest.this['target']) in str(e)
    assert pre == post
Пример #6
0
def test_bv_already_bumped_deep2(basic, tmpdir, already_setup):
    """
    If 'version.py' is already bumped, don't update it
    """
    pytest.dbgfunc()
    bf = pytest.basic_fx
    v = tmpdir.join(pytest.this['target'])
    with tbx.chdir(v.dirname):
        pre = tbx.contents(v.basename)
        with pytest.raises(SystemExit) as e:
            gitr.gitr_bv({'bv': True, '<path>': None})
        post = tbx.contents(v.basename)
    assert bf['already'].format(pytest.this['target']) in str(e)
    assert pre == post
Пример #7
0
def test_contents_str(tmpdir):
    """
    Test getting the contents of a file
    """
    pytest.dbgfunc()
    pt = pytest.this
    c = tbx.contents(pt['tfn'].strpath)
    assert c == ''.join([x + '\n' for x in pt['td']])
Пример #8
0
def test_contents_list(tmpdir, contents_setup):
    """
    Test getting the contents of a file
    """
    pytest.dbgfunc()
    pt = pytest.this
    c = tbx.contents(pt['tfn'].strpath, type=list)
    assert c == [x + '\n' for x in pt['td']]
Пример #9
0
def test_contents_default(tmpdir):
    """
    Test getting the contents of a file
    """
    pytest.dbgfunc()
    pt = pytest.this
    c = tbx.contents(pt['tfn'].strpath + "_nonesuch", default="take this instead")
    assert "take this instead" in c
Пример #10
0
def test_contents_fail(tmpdir):
    """
    Test getting the contents of a file
    """
    pytest.dbgfunc()
    pt = pytest.this
    with pytest.raises(IOError) as e:
        c = tbx.contents(pt['tfn'].strpath + "_nonesuch")
    assert "No such file or directory" in str(e)
Пример #11
0
def test_vu_on_tns(tmpdir):
    """
    old is None, target does not exist
    exp: write standard version expression to target
    """
    pytest.dbgfunc()
    trg = tmpdir.join('version.py')
    v = '9.8.7'
    with tbx.chdir(tmpdir.strpath):
        gitr.version_update(trg.strpath, v.split('.'))
    assert tbx.contents(trg.strpath) == "__version__ = '{0}'\n".format(v)
Пример #12
0
def test_vu_on_tns(tmpdir):
    """
    old is None, target does not exist
    exp: write standard version expression to target
    """
    pytest.dbgfunc()
    trg = tmpdir.join('version.py')
    v = '9.8.7'
    with tbx.chdir(tmpdir.strpath):
        gitr.version_update(trg.strpath, v.split('.'))
    assert tbx.contents(trg.strpath) == "__version__ = '{0}'\n".format(v)
Пример #13
0
def test_vu_os_tfl_op(tmpdir):
    """
    old is not None, target is not empty, old IS in target, non-standard
    exp: <olds> replaced with <news> in non-standard expression
    """
    pytest.dbgfunc()
    oldv, newv = '7.3.2.32', '7.3.2.33'
    trg = tmpdir.join('fooble-de-bar')

    t = '"{0}" is the version\n'
    (pre, post) = (t.format(_) for _ in [oldv, newv])
    trg.write(pre)
    with tbx.chdir(tmpdir.strpath):
        gitr.version_update(trg.basename, newv.split('.'), oldv.split('.'))
        assert post in tbx.contents(trg.basename)
Пример #14
0
def test_vu_os_tfl_op(tmpdir):
    """
    old is not None, target is not empty, old IS in target, non-standard
    exp: <olds> replaced with <news> in non-standard expression
    """
    pytest.dbgfunc()
    oldv, newv = '7.3.2.32', '7.3.2.33'
    trg = tmpdir.join('fooble-de-bar')

    t = '"{0}" is the version\n'
    (pre, post) = (t.format(_) for _ in [oldv, newv])
    trg.write(pre)
    with tbx.chdir(tmpdir.strpath):
        gitr.version_update(trg.basename, newv.split('.'), oldv.split('.'))
        assert post in tbx.contents(trg.basename)