annotate tests/common.py @ 59:f4cc7ff53cf8

hglib: change import style
author Idan Kamara <idankk86@gmail.com>
date Fri, 19 Aug 2011 20:14:15 +0300
parents 3d413c54e048
children 730c42743ba3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
1 import os, sys, tempfile, shutil
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
2 import unittest
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
3
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
4 import hglib
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
5
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
6 class basetest(unittest.TestCase):
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
7 def setUp(self):
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
8 self._testtmp = os.environ["TESTTMP"] = os.environ["HOME"] = \
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
9 os.path.join(os.environ["HGTMP"], self.__class__.__name__)
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
10
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
11 os.mkdir(self._testtmp)
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
12 os.chdir(self._testtmp)
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
13 # until we can run norepo commands in the cmdserver
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
14 os.system('hg init')
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
15 self.client = hglib.open()
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
16
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
17 def tearDown(self):
58
3d413c54e048 tests: be prepared for basetest.setUp not being called
Idan Kamara <idankk86@gmail.com>
parents: 7
diff changeset
18 try:
3d413c54e048 tests: be prepared for basetest.setUp not being called
Idan Kamara <idankk86@gmail.com>
parents: 7
diff changeset
19 shutil.rmtree(self._testtmp)
3d413c54e048 tests: be prepared for basetest.setUp not being called
Idan Kamara <idankk86@gmail.com>
parents: 7
diff changeset
20 except AttributeError:
3d413c54e048 tests: be prepared for basetest.setUp not being called
Idan Kamara <idankk86@gmail.com>
parents: 7
diff changeset
21 pass # if our setUp was overriden
7
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
22
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
23 def append(self, path, *args):
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
24 f = open(path, 'a')
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
25 for a in args:
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
26 f.write(str(a))
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
27 f.close()