示例#1
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_nofile_noarg(basic, tmpdir):
    """
    pre: nothing
    gitr bv
    post: exception('version.py not found')
    """
    bf = pytest.basic_fx
    with tbx.chdir(tmpdir.strpath):
        r = git.Repo.init(tmpdir.strpath)
        with pytest.raises(SystemExit) as e:
            gitr.gitr_bv({'bv': True})
    assert bf['notfound'].format(bf['defname']) in str(e)
示例#2
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_nofile_noarg(basic, tmpdir):
    """
    pre: nothing
    gitr bv
    post: exception('version.py not found')
    """
    bf = pytest.basic_fx
    with tbx.chdir(tmpdir.strpath):
        r = git.Repo.init(tmpdir.strpath)
        with pytest.raises(SystemExit) as e:
            gitr.gitr_bv({'bv': True})
    assert bf['notfound'].format(bf['defname']) in str(e)
示例#3
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_norepo(basic, tmpdir):
    """
    pre: nothing
    gitr bv
    post: exception('version.py is not in a git repo')
    """
    bf = pytest.basic_fx
    v = tmpdir.join(bf['defname'])
    with tbx.chdir(tmpdir.strpath):
        v.write(bf['template'].format('0.0.0'))
        with pytest.raises(SystemExit) as e:
            gitr.gitr_bv({'bv': True})
    assert bf['notrepo'].format(bf['defname']) in str(e)
示例#4
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
示例#5
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
示例#6
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_nofile_major_fn(basic, tmpdir):
    """
    pre: nothing
    gitr bv --major frooble
    post: exception('frooble not found')
    """
    bf = pytest.basic_fx
    vname = 'frooble'
    with tbx.chdir(tmpdir.strpath):
        r = git.Repo.init(tmpdir.strpath)
        with pytest.raises(SystemExit) as e:
            gitr.gitr_bv({'bv': True, '--major': True, '<path>': vname})
        assert bf['notfound'].format(vname) in str(e)
示例#7
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
示例#8
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_patch_build(basic, tmpdir):
    """
    pre: nothing
    gitr bv --patch --build
    post: exception('--patch and --build are mutually exclusive')
    """
    bf = pytest.basic_fx
    mx_opt1, mx_opt2 = '--patch', '--build'
    exp = bf['mutex'].format(mx_opt1, mx_opt2)
    with tbx.chdir(tmpdir.strpath):
        with pytest.raises(SystemExit) as e:
            gitr.gitr_bv({mx_opt1: True, mx_opt2: True})
        assert exp in str(e)
示例#9
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_major_minor(basic, tmpdir, repo_setup):
    """
    pre: nothing
    gitr bv --major --minor
    post: exception('--major and --minor are mutually exclusive')
    """
    bf = pytest.basic_fx
    mx_opt1, mx_opt2 = '--major', '--minor'
    exp = bf['mutex'].format(mx_opt1, mx_opt2)
    with tbx.chdir(tmpdir.strpath):
        with pytest.raises(SystemExit) as e:
            gitr.gitr_bv({mx_opt1: True, mx_opt2: True})
        assert exp in str(e)
示例#10
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_major_minor(basic, tmpdir, repo_setup):
    """
    pre: nothing
    gitr bv --major --minor
    post: exception('--major and --minor are mutually exclusive')
    """
    bf = pytest.basic_fx
    mx_opt1, mx_opt2 = '--major', '--minor'
    exp = bf['mutex'].format(mx_opt1, mx_opt2)
    with tbx.chdir(tmpdir.strpath):
        with pytest.raises(SystemExit) as e:
            gitr.gitr_bv({mx_opt1: True, mx_opt2: True})
        assert exp in str(e)
示例#11
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
示例#12
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_norepo(basic, tmpdir):
    """
    pre: nothing
    gitr bv
    post: exception('version.py is not in a git repo')
    """
    bf = pytest.basic_fx
    v = tmpdir.join(bf['defname'])
    with tbx.chdir(tmpdir.strpath):
        v.write(bf['template'].format('0.0.0'))
        with pytest.raises(SystemExit) as e:
            gitr.gitr_bv({'bv': True})
    assert bf['notrepo'].format(bf['defname']) in str(e)
示例#13
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_patch_build(basic, tmpdir):
    """
    pre: nothing
    gitr bv --patch --build
    post: exception('--patch and --build are mutually exclusive')
    """
    bf = pytest.basic_fx
    mx_opt1, mx_opt2 = '--patch', '--build'
    exp = bf['mutex'].format(mx_opt1, mx_opt2)
    with tbx.chdir(tmpdir.strpath):
        with pytest.raises(SystemExit) as e:
            gitr.gitr_bv({mx_opt1: True, mx_opt2: True})
        assert exp in str(e)
示例#14
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_nofile_major_fn(basic, tmpdir):
    """
    pre: nothing
    gitr bv --major frooble
    post: exception('frooble not found')
    """
    bf = pytest.basic_fx
    vname = 'frooble'
    with tbx.chdir(tmpdir.strpath):
        r = git.Repo.init(tmpdir.strpath)
        with pytest.raises(SystemExit) as e:
            gitr.gitr_bv({'bv': True, '--major': True, '<path>': vname})
        assert bf['notfound'].format(vname) in str(e)
示例#15
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
示例#16
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
示例#17
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_nofile_patch(basic, tmpdir, repo_setup):
    """
    pre: nothing
    gitr bv --patch
    post: exception('version.py not found')
    """
    bf = pytest.basic_fx
    v = pytest.this['vname']
    v.remove()
    q = pytest.this['q']
    q['foo/bar/version.py']['locpath'].remove()
    with tbx.chdir(tmpdir.strpath):
        with pytest.raises(SystemExit) as e:
            gitr.gitr_bv({'--patch': True})
        assert bf['notfound'].format(v.basename) in str(e)
示例#18
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_nofile_patch(basic, tmpdir, repo_setup):
    """
    pre: nothing
    gitr bv --patch
    post: exception('version.py not found')
    """
    bf = pytest.basic_fx
    v = pytest.this['vname']
    v.remove()
    q = pytest.this['q']
    q['foo/bar/version.py']['locpath'].remove()
    with tbx.chdir(tmpdir.strpath):
        with pytest.raises(SystemExit) as e:
            gitr.gitr_bv({'--patch': True})
        assert bf['notfound'].format(v.basename) in str(e)
示例#19
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_file_patch_4(basic, tmpdir, capsys, repo_setup):
    """
    pre: '1.3.2.7' in version.py
    gitr bv --patch
    post: '1.3.3' in version.py
    """
    bf = pytest.basic_fx
    r = pytest.this['repo']
    v = pytest.this['vname']
    pre, post = "1.3.2.7", "1.3.3"
    v.write(bf['template'].format(pre))
    r.git.commit(a=True, m='first version')
    with tbx.chdir(tmpdir.strpath):
        gitr.gitr_bv({'bv': True, '--patch': True})
        bv_verify_diff(bf['template'], pre, post, capsys.readouterr())
    assert bf['template'].format(post) in v.read()
示例#20
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_file_major_4(basic, tmpdir, capsys, repo_setup):
    """
    pre: '1.0.0.17' in version.py
    gitr bv --major
    post: '2.0.0' in version.py
    """
    bf = pytest.basic_fx
    r = pytest.this['repo']
    v = pytest.this['vname']
    pre, post = '1.0.0.17', '2.0.0'
    v.write(bf['template'].format(pre))
    r.git.commit(a=True, m='set version')
    with tbx.chdir(tmpdir.strpath):
        gitr.gitr_bv({'bv': True, '--major': True, '<path>': v.basename})
        bv_verify_diff(bf['template'], pre, post, capsys.readouterr())
    assert bf['template'].format(post) in v.read()
示例#21
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_file_major_3_fn(basic, tmpdir, capsys, repo_setup):
    """
    pre: '7.4.3' in splack
    gitr bv --major splack
    post: '8.0.0' in splack
    """
    bf = pytest.basic_fx
    r = pytest.this['repo']
    o = pytest.this['other']
    pre, post = "7.4.3", "8.0.0"
    o.write("__version__ = '{0}'\n".format(pre))
    r.git.commit(a=True, m='set a version')
    with tbx.chdir(tmpdir.strpath):
        gitr.gitr_bv({'bv': True, '--major': True, '<path>': o.basename})
    assert bf['template'].format(post) in o.read()
    bv_verify_diff(bf['template'], pre, post, capsys.readouterr())
示例#22
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_file_patch_4(basic, tmpdir, capsys, repo_setup):
    """
    pre: '1.3.2.7' in version.py
    gitr bv --patch
    post: '1.3.3' in version.py
    """
    bf = pytest.basic_fx
    r = pytest.this['repo']
    v = pytest.this['vname']
    pre, post = "1.3.2.7", "1.3.3"
    v.write(bf['template'].format(pre))
    r.git.commit(a=True, m='first version')
    with tbx.chdir(tmpdir.strpath):
        gitr.gitr_bv({'bv': True, '--patch': True})
        bv_verify_diff(bf['template'], pre, post, capsys.readouterr())
    assert bf['template'].format(post) in v.read()
示例#23
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_file_noarg_4(basic, tmpdir, capsys):
    """
    pre: 2.7.3.8 in version.py
    gitr bv
    post: 2.7.3.9 in version.py
    """
    bf = pytest.basic_fx
    pre, post = ('2.7.3.8', '2.7.3.9')
    vpath = tmpdir.join(bf['defname'])
    vpath.write(bf['template'].format(pre))
    r = git.Repo.init(tmpdir.strpath)
    with tbx.chdir(tmpdir.strpath):
        r.git.add(vpath.basename)
        r.git.commit(m='inception')
        gitr.gitr_bv({'bv': True})
        bv_verify_diff(bf['template'], pre, post, capsys.readouterr())
    assert post in vpath.read()
示例#24
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_file_major_4(basic, tmpdir, capsys, repo_setup):
    """
    pre: '1.0.0.17' in version.py
    gitr bv --major
    post: '2.0.0' in version.py
    """
    bf = pytest.basic_fx
    r = pytest.this['repo']
    v = pytest.this['vname']
    pre, post = '1.0.0.17', '2.0.0'
    v.write(bf['template'].format(pre))
    r.git.commit(a=True, m='set version')
    with tbx.chdir(tmpdir.strpath):
        gitr.gitr_bv({'bv': True, '--major': True,
                      '<path>': v.basename})
        bv_verify_diff(bf['template'], pre, post, capsys.readouterr())
    assert bf['template'].format(post) in v.read()
示例#25
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_file_patch_3(basic, tmpdir, repo_setup, capsys):
    """
    pre: '1.3.2' in version.py
    gitr bv --patch
    post: '1.3.3' in version.py
    """
    bf = pytest.basic_fx
    pre, post = '1.3.2', '1.3.3'
    r = pytest.this['repo']
    v = pytest.this['vname']
    v.write(bf['template'].format(pre))
    r.git.commit(a=True, m='first version')
    with tbx.chdir(tmpdir.strpath):
        gitr.gitr_bv({'bv': True, '--patch': True, '-q': True})
        o, e = capsys.readouterr()
        assert o.strip() == ""
    assert bf['template'].format(post) in v.read()
示例#26
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_dir_nofile(basic, tmpdir):
    """
    pre: '/' in target; dirname(target) exists; target does not
    gitr bv <target-path>
    post: no traceback
    """
    bf = pytest.basic_fx
    (sub, trg) = ('sub', 'trg')
    sub_lp = tmpdir.join(sub).ensure(dir=True)
    trg_lp = sub_lp.join(trg)
    rel = '{0}/{1}'.format(sub, trg)
    r = git.Repo.init(tmpdir.strpath)
    with tbx.chdir(tmpdir.strpath):
        with pytest.raises(SystemExit) as e:
            gitr.gitr_bv({'bv': True, '<path>': rel})
            assert bf['nodiff'].format(rel) in str(e)
    assert "'0.0.0'" in trg_lp.read()
示例#27
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_file_major_3_fn(basic, tmpdir, capsys, repo_setup):
    """
    pre: '7.4.3' in splack
    gitr bv --major splack
    post: '8.0.0' in splack
    """
    bf = pytest.basic_fx
    r = pytest.this['repo']
    o = pytest.this['other']
    pre, post = "7.4.3", "8.0.0"
    o.write("__version__ = '{0}'\n".format(pre))
    r.git.commit(a=True, m='set a version')
    with tbx.chdir(tmpdir.strpath):
        gitr.gitr_bv({'bv': True, '--major': True,
                      '<path>': o.basename})
    assert bf['template'].format(post) in o.read()
    bv_verify_diff(bf['template'], pre, post, capsys.readouterr())
示例#28
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_file_minor_4_fn(basic, tmpdir, repo_setup):
    """
    pre: '3.3.2.7' in version.py
    gitr bv --minor frockle
    post: '3.3.2.7' in version.py, exception('frockle not found')
    """
    bf = pytest.basic_fx
    r = pytest.this['repo']
    v = pytest.this['vname']
    fn = 'frockle'
    pre, post = "3.3.2.7", "3.4.0"
    v.write(bf['template'].format(pre))
    r.git.commit(a=True, m='first version')
    with tbx.chdir(tmpdir.strpath):
        with pytest.raises(SystemExit) as e:
            gitr.gitr_bv({'bv': True, '--minor': True, '<path>': fn})
        assert bf['notfound'].format(fn) in str(e)
示例#29
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_file_patch_3(basic, tmpdir, repo_setup, capsys):
    """
    pre: '1.3.2' in version.py
    gitr bv --patch
    post: '1.3.3' in version.py
    """
    bf = pytest.basic_fx
    pre, post = '1.3.2', '1.3.3'
    r = pytest.this['repo']
    v = pytest.this['vname']
    v.write(bf['template'].format(pre))
    r.git.commit(a=True, m='first version')
    with tbx.chdir(tmpdir.strpath):
        gitr.gitr_bv({'bv': True, '--patch': True, '-q': True})
        o, e = capsys.readouterr()
        assert o.strip() == ""
    assert bf['template'].format(post) in v.read()
示例#30
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_file_build_deep(basic, tmpdir, repo_setup):
    """
    pre: '7.8.9' in ./pkg/foobar
    gitr bv --build ./pkg/foobar
    post: '7.8.9.1' in ./pkg/foobar
    """
    bf = pytest.basic_fx
    r = pytest.this['repo']
    pre, post = '7.8.9', '7.8.9.1'
    t = pytest.this['template']
    op = 'foo/bar/other_name'
    o = pytest.this['q'][op]
    o['locpath'].write(t.format(pre))
    r.git.commit(a=True, m='version')
    with tbx.chdir(o['locpath'].dirname):
        gitr.gitr_bv({'--build': True, '<path>': o['locpath'].basename})
    assert t.format(post) in o['locpath'].read()
示例#31
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_dir_nofile(basic, tmpdir):
    """
    pre: '/' in target; dirname(target) exists; target does not
    gitr bv <target-path>
    post: no traceback
    """
    bf = pytest.basic_fx
    (sub, trg) = ('sub', 'trg')
    sub_lp = tmpdir.join(sub).ensure(dir=True)
    trg_lp = sub_lp.join(trg)
    rel = '{0}/{1}'.format(sub, trg)
    r = git.Repo.init(tmpdir.strpath)
    with tbx.chdir(tmpdir.strpath):
        with pytest.raises(SystemExit) as e:
            gitr.gitr_bv({'bv': True, '<path>': rel})
            assert bf['nodiff'].format(rel) in str(e)
    assert "'0.0.0'" in trg_lp.read()
示例#32
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_file_noarg_4(basic, tmpdir, capsys):
    """
    pre: 2.7.3.8 in version.py
    gitr bv
    post: 2.7.3.9 in version.py
    """
    bf = pytest.basic_fx
    pre, post = ('2.7.3.8', '2.7.3.9')
    vpath = tmpdir.join(bf['defname'])
    vpath.write(bf['template'].format(pre))
    r = git.Repo.init(tmpdir.strpath)
    with tbx.chdir(tmpdir.strpath):
        r.git.add(vpath.basename)
        r.git.commit(m='inception')
        gitr.gitr_bv({'bv': True})
        bv_verify_diff(bf['template'], pre, post, capsys.readouterr())
    assert post in vpath.read()
示例#33
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_file_major_3(basic, tmpdir, capsys, repo_setup):
    """
    pre: '7.4.3' in version.py
    gitr bv --major --quiet
    post: '8.0.0' in version.py, nothing on stdout
    """
    bf = pytest.basic_fx
    pre, post = '7.4.3', '8.0.0'
    r = pytest.this['repo']
    v = pytest.this['vname']
    v.write(pre)
    r.git.commit(a=True, m='set version')
    with tbx.chdir(tmpdir.strpath):
        gitr.gitr_bv({'bv': True, '--major': True, '--quiet': True})
    assert post in v.read()
    assert 'M version.py' in r.git.status(porc=True)
    o, e = capsys.readouterr()
    assert o.strip() == ""
示例#34
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_file_minor_4_fn(basic, tmpdir, repo_setup):
    """
    pre: '3.3.2.7' in version.py
    gitr bv --minor frockle
    post: '3.3.2.7' in version.py, exception('frockle not found')
    """
    bf = pytest.basic_fx
    r = pytest.this['repo']
    v = pytest.this['vname']
    fn = 'frockle'
    pre, post = "3.3.2.7", "3.4.0"
    v.write(bf['template'].format(pre))
    r.git.commit(a=True, m='first version')
    with tbx.chdir(tmpdir.strpath):
        with pytest.raises(SystemExit) as e:
            gitr.gitr_bv({'bv': True, '--minor': True,
                          '<path>': fn})
        assert bf['notfound'].format(fn) in str(e)
示例#35
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_nofile_major_3_fn(basic, tmpdir, repo_setup):
    """
    pre: '7.4.3' in splack
    gitr bv --major flump
    post: exception('flump not found')
    """
    bf = pytest.basic_fx
    pre = post = '7.4.3'
    r = pytest.this['repo']
    n = pytest.this['nosuch']
    o = pytest.this['other']
    o.write(bf['template'].format(pre))
    r.git.commit(a=True, m='set version')
    with tbx.chdir(tmpdir.strpath):
        with pytest.raises(SystemExit) as e:
            gitr.gitr_bv({'bv': True, '--major': True, '<path>': n.basename})
        assert bf['notfound'].format(n.basename) in str(e)
    assert bf['template'].format(post) in o.read()
示例#36
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_file_major_3(basic, tmpdir, capsys, repo_setup):
    """
    pre: '7.4.3' in version.py
    gitr bv --major --quiet
    post: '8.0.0' in version.py, nothing on stdout
    """
    bf = pytest.basic_fx
    pre, post = '7.4.3', '8.0.0'
    r = pytest.this['repo']
    v = pytest.this['vname']
    v.write(pre)
    r.git.commit(a=True, m='set version')
    with tbx.chdir(tmpdir.strpath):
        gitr.gitr_bv({'bv': True, '--major': True, '--quiet': True})
    assert post in v.read()
    assert 'M version.py' in r.git.status(porc=True)
    o, e = capsys.readouterr()
    assert o.strip() == ""
示例#37
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_file_build_4(basic, tmpdir, capsys, repo_setup):
    """
    pre: '1.2.3.4' in foo/bar/version.py
    gitr bv --build
    post: '1.2.3.5' in foo/bar/version.py
    """
    bf = pytest.basic_fx
    r = pytest.this['repo']
    pytest.this['vname'].remove()
    vp = 'foo/bar/version.py'
    v = pytest.this['q'][vp]
    pre, post = "1.2.3.4", "1.2.3.5"
    t = pytest.this['template']
    v['locpath'].write(t.format(pre))
    r.git.commit(a=True, m='first version')
    with tbx.chdir(tmpdir.strpath):
        gitr.gitr_bv({'bv': True, '--build': True})
        bv_verify_diff(t, pre, post, capsys.readouterr())
示例#38
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_file_build_deep(basic, tmpdir, repo_setup):
    """
    pre: '7.8.9' in ./pkg/foobar
    gitr bv --build ./pkg/foobar
    post: '7.8.9.1' in ./pkg/foobar
    """
    bf = pytest.basic_fx
    r = pytest.this['repo']
    pre, post = '7.8.9', '7.8.9.1'
    t = pytest.this['template']
    op = 'foo/bar/other_name'
    o = pytest.this['q'][op]
    o['locpath'].write(t.format(pre))
    r.git.commit(a=True, m='version')
    with tbx.chdir(o['locpath'].dirname):
        gitr.gitr_bv({'--build': True,
                      '<path>': o['locpath'].basename})
    assert t.format(post) in o['locpath'].read()
示例#39
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_nofile_fnarg(basic, tmpdir):
    """
    pre: nothing
    gitr bv a/b/flotsam
    post: '0.0.0' in a/b/flotsam
    """
    bf = pytest.basic_fx
    dpath = tmpdir.join('a/b')
    bvpath = dpath.join('flotsam')
    assert not bvpath.exists()
    r = git.Repo.init(tmpdir.strpath)
    with tbx.chdir(tmpdir.strpath):
        rpath = bvpath.relto(tmpdir)
        with pytest.raises(SystemExit) as e:
            gitr.gitr_bv({'bv': True, '<path>': rpath})
        assert bf['nodiff'].format(rpath) in str(e)
    assert bvpath.exists()
    assert "'0.0.0'" in bvpath.read()
示例#40
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_nofile_fnarg(basic, tmpdir):
    """
    pre: nothing
    gitr bv a/b/flotsam
    post: '0.0.0' in a/b/flotsam
    """
    bf = pytest.basic_fx
    dpath = tmpdir.join('a/b')
    bvpath = dpath.join('flotsam')
    assert not bvpath.exists()
    r = git.Repo.init(tmpdir.strpath)
    with tbx.chdir(tmpdir.strpath):
        rpath = bvpath.relto(tmpdir)
        with pytest.raises(SystemExit) as e:
            gitr.gitr_bv({'bv': True, '<path>': rpath})
        assert bf['nodiff'].format(rpath) in str(e)
    assert bvpath.exists()
    assert "'0.0.0'" in bvpath.read()
示例#41
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_file_minor_3_fn(basic, tmpdir, capsys, repo_setup):
    """
    pre: '3.3.2' in foo/bar/setup.py
    gitr bv --minor foo/bar/setup.py
    post: '3.4.0' in foo/bar/setup.py
    """
    bf = pytest.basic_fx
    r = pytest.this['repo']
    v = pytest.this['vname']
    d = tmpdir.join('foo/bar').ensure(dir=True)
    s = d.join('setup.py')
    pre, post = "3.3.2", "3.4.0"
    s.write(bf['template'].format(pre))
    r.git.add(s.strpath)
    r.git.commit(a=True, m='first version')
    with tbx.chdir(tmpdir.strpath):
        gitr.gitr_bv({'bv': True, '--minor': True, '<path>': s.relto(tmpdir)})
        bv_verify_diff(bf['template'], pre, post, capsys.readouterr())
    assert bf['template'].format(post) in s.read()
示例#42
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_nofile_major_3_fn(basic, tmpdir, repo_setup):
    """
    pre: '7.4.3' in splack
    gitr bv --major flump
    post: exception('flump not found')
    """
    bf = pytest.basic_fx
    pre = post = '7.4.3'
    r = pytest.this['repo']
    n = pytest.this['nosuch']
    o = pytest.this['other']
    o.write(bf['template'].format(pre))
    r.git.commit(a=True, m='set version')
    with tbx.chdir(tmpdir.strpath):
        with pytest.raises(SystemExit) as e:
            gitr.gitr_bv({'bv': True, '--major': True,
                          '<path>': n.basename})
        assert bf['notfound'].format(n.basename) in str(e)
    assert bf['template'].format(post) in o.read()
示例#43
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_file_build_4(basic, tmpdir, capsys, repo_setup):
    """
    pre: '1.2.3.4' in foo/bar/version.py
    gitr bv --build
    post: '1.2.3.5' in foo/bar/version.py
    """
    bf = pytest.basic_fx
    r = pytest.this['repo']
    pytest.this['vname'].remove()
    vp = 'foo/bar/version.py'
    v = pytest.this['q'][vp]
    pre, post = "1.2.3.4", "1.2.3.5"
    t = pytest.this['template']
    v['locpath'].write(t.format(pre))
    r.git.commit(a=True, m='first version')
    with tbx.chdir(tmpdir.strpath):
        gitr.gitr_bv({'bv': True, '--build': True})
        bv_verify_diff(t, pre, post,
                       capsys.readouterr())
示例#44
0
文件: test_gitr.py 项目: tbarron/gitr
def test_bv_file_minor_3_fn(basic, tmpdir, capsys, repo_setup):
    """
    pre: '3.3.2' in foo/bar/setup.py
    gitr bv --minor foo/bar/setup.py
    post: '3.4.0' in foo/bar/setup.py
    """
    bf = pytest.basic_fx
    r = pytest.this['repo']
    v = pytest.this['vname']
    d = tmpdir.join('foo/bar').ensure(dir=True)
    s = d.join('setup.py')
    pre, post = "3.3.2", "3.4.0"
    s.write(bf['template'].format(pre))
    r.git.add(s.strpath)
    r.git.commit(a=True, m='first version')
    with tbx.chdir(tmpdir.strpath):
        gitr.gitr_bv({'bv': True, '--minor': True,
                      '<path>': s.relto(tmpdir)})
        bv_verify_diff(bf['template'], pre, post, capsys.readouterr())
    assert bf['template'].format(post) in s.read()