コード例 #1
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)
コード例 #2
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)
コード例 #3
0
ファイル: test_gitr.py プロジェクト: tbarron/gitr
def test_vu_os_tmt(tmpdir):
    """
    old is not None, target is empty
    exp: 'Can't update '<olds>' in an empty file'
    """
    pytest.dbgfunc()
    trg = tmpdir.join('version.py')
    oldv, newv = '9.8.6', '9.8.7'
    trg.write('')
    with tbx.chdir(tmpdir.strpath):
        with pytest.raises(SystemExit) as e:
            gitr.version_update(trg.strpath, newv.split('.'), oldv.split('.'))
        assert ''.join(["Can't update '", oldv,
                        "' in an empty file"]) in str(e)
コード例 #4
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)
コード例 #5
0
ファイル: test_gitr.py プロジェクト: tbarron/gitr
def test_vu_os_tmt(tmpdir):
    """
    old is not None, target is empty
    exp: 'Can't update '<olds>' in an empty file'
    """
    pytest.dbgfunc()
    trg = tmpdir.join('version.py')
    oldv, newv = '9.8.6', '9.8.7'
    trg.write('')
    with tbx.chdir(tmpdir.strpath):
        with pytest.raises(SystemExit) as e:
            gitr.version_update(trg.strpath, newv.split('.'), oldv.split('.'))
        assert ''.join(["Can't update '",
                        oldv,
                        "' in an empty file"]) in str(e)
コード例 #6
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)
コード例 #7
0
ファイル: test_gitr.py プロジェクト: tbarron/gitr
def test_vu_on_tfl(tmpdir):
    """
    old is None, target is not empty
    exp: 'Don't know where to put '<news>' in '<c>''
    """
    pytest.dbgfunc()
    trg = tmpdir.join('version.py')
    nov = 'The quick brown fox and all that'
    trg.write(nov)
    v = '9.8.7'
    with tbx.chdir(tmpdir.strpath):
        with pytest.raises(SystemExit) as e:
            gitr.version_update(trg.strpath, v.split('.'))
        assert ''.join(["Don't know where to put '", v, "' in '", nov,
                        "'"]) in str(e)
コード例 #8
0
ファイル: test_gitr.py プロジェクト: tbarron/gitr
def test_vu_os_tfl_onp(tmpdir):
    """
    old is not None, target is not empty, old is not in target
    exp: '<olds>' not found in '<c>'
    """
    pytest.dbgfunc()
    oldv, newv = '7.3.2.32', '7.3.2.33'
    trg = tmpdir.join('fooble-de-bar')

    t = '"sizzle" is the version'
    (pre, post) = (t.format(_) for _ in [oldv, newv])
    trg.write(pre)
    exp = "'{0}' not found in '{1}'".format(oldv, pre)
    with tbx.chdir(tmpdir.strpath):
        with pytest.raises(SystemExit) as e:
            gitr.version_update(trg.basename, newv.split('.'), oldv.split('.'))
        assert exp in str(e)
コード例 #9
0
ファイル: test_gitr.py プロジェクト: tbarron/gitr
def test_vu_os_tfl_onp(tmpdir):
    """
    old is not None, target is not empty, old is not in target
    exp: '<olds>' not found in '<c>'
    """
    pytest.dbgfunc()
    oldv, newv = '7.3.2.32', '7.3.2.33'
    trg = tmpdir.join('fooble-de-bar')

    t = '"sizzle" is the version'
    (pre, post) = (t.format(_) for _ in [oldv, newv])
    trg.write(pre)
    exp = "'{0}' not found in '{1}'".format(oldv, pre)
    with tbx.chdir(tmpdir.strpath):
        with pytest.raises(SystemExit) as e:
            gitr.version_update(trg.basename, newv.split('.'), oldv.split('.'))
        assert exp in str(e)
コード例 #10
0
ファイル: test_gitr.py プロジェクト: tbarron/gitr
def test_vu_on_tfl(tmpdir):
    """
    old is None, target is not empty
    exp: 'Don't know where to put '<news>' in '<c>''
    """
    pytest.dbgfunc()
    trg = tmpdir.join('version.py')
    nov = 'The quick brown fox and all that'
    trg.write(nov)
    v = '9.8.7'
    with tbx.chdir(tmpdir.strpath):
        with pytest.raises(SystemExit) as e:
            gitr.version_update(trg.strpath, v.split('.'))
        assert ''.join(["Don't know where to put '",
                        v,
                        "' in '",
                        nov,
                        "'"]) in str(e)