tests/test_branch.py @ e2d60e4e3caf

Fix error: don't assume status is a tuple

This fix also works with older versions of Mercurial. `repo.status()` used to
return a named tuple; since 5.2.1 it returns an object. So `st[:5]` no longer
works, but `st.modified` works with both old and new versions of Mercurial.
author Sietse Brouwer <sbbrouwer@gmail.com>
date Tue, 26 May 2020 14:57:58 +0200
parents 724156256017
children (none)
'''Test output of {branch}.'''

from nose import *
from util import *


@with_setup(setup_sandbox, teardown_sandbox)
def test_default_branch():
    output = prompt(fs='{branch}')
    assert output == 'default'
    
    output = prompt(fs='{on {branch}}')
    assert output == 'on default'


@with_setup(setup_sandbox, teardown_sandbox)
def test_non_default_branch():
    hg_branch('test')
    
    output = prompt(fs='{branch}')
    assert output == 'test'
    
    output = prompt(fs='{on the {branch} branch}')
    assert output == 'on the test branch'


@with_setup(setup_sandbox, teardown_sandbox)
def test_quiet_filter():
    output = prompt(fs='{branch|quiet}')
    assert output == ''
    
    output = prompt(fs='{on {branch|quiet}}')
    assert output == ''
    
    hg_branch('test')
    
    output = prompt(fs='{branch|quiet}')
    assert output == 'test'
    
    output = prompt(fs='{on the {branch|quiet} branch}')
    assert output == 'on the test branch'