예제 #1
0
파일: test_gitr.py 프로젝트: tbarron/gitr
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
파일: test_gitr.py 프로젝트: tbarron/gitr
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
파일: test_gitr.py 프로젝트: tbarron/gitr
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
파일: test_gitr.py 프로젝트: tbarron/gitr
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
파일: test_gitr.py 프로젝트: tbarron/gitr
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
파일: test_gitr.py 프로젝트: tbarron/gitr
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
파일: test_tbx.py 프로젝트: tbarron/gitr
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
파일: test_tbx.py 프로젝트: tbarron/gitr
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
파일: test_tbx.py 프로젝트: tbarron/gitr
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
파일: test_tbx.py 프로젝트: tbarron/gitr
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
파일: test_gitr.py 프로젝트: tbarron/gitr
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
파일: test_gitr.py 프로젝트: tbarron/gitr
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
파일: test_gitr.py 프로젝트: tbarron/gitr
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
파일: test_gitr.py 프로젝트: tbarron/gitr
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)