tests/test_node.py @ 16aa2def1d5b default tip

Update to work with Python 3

The Hamster Wheel of Backwards Incompatibility turns ever onward.  This probably
breaks support for Python 2, but at this point I don't care.  I just can't
summon up the willpower to do anything more than the most basic unfucking of
this thing that's been finished for 11 years but still breaks constantly because
of Mercurial's API churn and Python 3 setting the world on fire.

                                                                                    The
_  _ ____ _  _ ____ ___ ____ ____    _ _ _ _  _ ____ ____ _       ____ ____    ___  ____ ____ _  _ _ _ _ ____ ____ ___  ____    _ _  _ ____ ____ _  _ ___  ____ ___ _ ___  _ _    _ ___ _   _
|__| |__| |\/| [__   |  |___ |__/    | | | |__| |___ |___ |       |  | |___    |__] |__| |    |_/  | | | |__| |__/ |  \ [__     | |\ | |    |  | |\/| |__] |__|  |  | |__] | |    |  |   \_/
|  | |  | |  | ___]  |  |___ |  \    |_|_| |  | |___ |___ |___    |__| |       |__] |  | |___ | \_ |_|_| |  | |  \ |__/ ___]    | | \| |___ |__| |  | |    |  |  |  | |__] | |___ |  |    |
                                                                                turns forever
author Steve Losh <steve@stevelosh.com>
date Tue, 06 Apr 2021 12:55:48 -0400
parents a85dc0c43f86
children (none)
'''Test output of {node}.'''

from nose import *
from util import *


def _parent_node():
    opts = { 'template': '{node}', 'rev': '.', 'date': None, 'user': None }
    
    _ui = get_sandbox_ui()
    _ui.pushbuffer()
    commands.log(_ui, get_sandbox_repo(), **opts)
    
    return _ui.popbuffer()


@with_setup(setup_sandbox, teardown_sandbox)
def test_node():
    output = prompt(fs='{node}')
    assert output == '0000000000000000000000000000000000000000'
    
    output = prompt(fs='{ at node {node}}')
    assert output == ' at node 0000000000000000000000000000000000000000'
    
    hg_commit()
    output = prompt(fs='{node}')
    assert output == _parent_node()
    
    hg_commit()
    output = prompt(fs='{node}')
    assert output == _parent_node()
    
    hg_update(0)
    output = prompt(fs='{node}')
    assert output == _parent_node()


@with_setup(setup_sandbox, teardown_sandbox)
def test_short_filter():
    output = prompt(fs='{node|short}')
    assert output == '0000000000000000000000000000000000000000'[:12]
    
    output = prompt(fs='{ at node {node|short}}')
    assert output == ' at node ' + '0000000000000000000000000000000000000000'[:12]
    
    hg_commit()
    output = prompt(fs='{node|short}')
    assert output == _parent_node()[:12]
    
    hg_commit()
    output = prompt(fs='{node|short}')
    assert output == _parent_node()[:12]
    
    hg_update(0)
    output = prompt(fs='{node|short}')
    assert output == _parent_node()[:12]


@with_setup(setup_sandbox, teardown_sandbox)
def test_merge_filter():
    hg_commit('one.txt')
    hg_commit('one.txt')
    node_to_merge = _parent_node()
    
    hg_update(0)
    hg_commit('two.txt')
    hg_merge(1)
    
    output = prompt(fs='{node|merge}')
    assert output == node_to_merge
    
    output = prompt(fs='{node|merge|short}')
    assert output == node_to_merge[:12]