review/tests/test_init.py @ 29d79d253294

Fix the sandbox committing.
author Steve Losh <steve@stevelosh.com>
date Sun, 04 Oct 2009 15:43:27 -0400
parents 3e7777d0654e
children 1fcd33358670
from nose import *
from mercurial import commands, hg, ui
import os, shutil
import sample_data


sandbox_path = os.path.join(os.path.realpath('.'), 'hgreview_test')

def setup_sandbox():
    os.mkdir(sandbox_path)
    os.chdir(sandbox_path)
    
    commands.init(ui.ui())
    sandbox = get_sandbox_repo()
    
    opts = { 'addremove': True, 'date': None, 'user': 'Review Tester',
             'logfile': None, 'message': "Sandbox commit.", }
    for state in sample_data.log:
        for filename in state:
            with open(filename, 'w') as f:
                f.write(state[filename])
        commands.commit(ui.ui(), sandbox, **opts)

def teardown_sandbox():
    os.chdir(os.path.realpath(os.path.join(sandbox_path, os.pardir)))
    # shutil.rmtree(sandbox_path)

def get_sandbox_repo():
    return hg.repository(ui.ui(), '.')


@with_setup(setup_sandbox, teardown_sandbox)
def test_default_init():
    sandbox = get_sandbox_repo()