tests/test_branch.py @ c4095c3519d6

Fixed bug that was thowing a KeyError when including "{bookmark}" in the output.

This resolves issue #17 (Bookmarks have moved into core for 1.8) on https://bitbucket.org/sjl/hg-prompt/.

The end of the stack track was....
-----------------------------
  File "/Users/dak180/Applications/Build/hgExtensions/hg-prompt/prompt.py", line 101, in _bookmark
    book = extensions.find('bookmarks').current(repo)
  File "/sw/lib/python2.6/site-packages/mercurial/extensions.py", line 30, in find
    raise KeyError(name)
KeyError: 'bookmarks'
-----------------------------

I personally was getting this error on mercurial versions 1.8.1 and 1.6.3 (although I am not exactly sure why I got it on 1.6.3).
author Shaun Ek <shaune@providentmetals.com>
date Wed, 23 Mar 2011 15:42:04 -0400
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'