view tests/common.py @ 7:eac8be119d81

tests: rearrange tests and use nosetests - provide package setup/teardown methods that fixes the environment - introduce a basetest that initializes a repository in a temp dir
author Idan Kamara <idankk86@gmail.com>
date Sat, 23 Jul 2011 22:55:39 +0300
parents
children 3d413c54e048
line wrap: on
line source

import os, sys, tempfile, shutil
import unittest

import hglib

class basetest(unittest.TestCase):
    def setUp(self):
        self._testtmp = os.environ["TESTTMP"] = os.environ["HOME"] = \
            os.path.join(os.environ["HGTMP"], self.__class__.__name__)

        os.mkdir(self._testtmp)
        os.chdir(self._testtmp)
        # until we can run norepo commands in the cmdserver
        os.system('hg init')
        self.client = hglib.open()

    def tearDown(self):
        shutil.rmtree(self._testtmp)

    def append(self, path, *args):
        f = open(path, 'a')
        for a in args:
            f.write(str(a))
        f.close()