comparison tests/common.py @ 219:8341f2494b3f

hglib tests: migrate away from (unmaintained) nose
author Mathias De Mare <mathias.de_mare@nokia.com>
date Wed, 08 Mar 2023 17:04:58 +0100
parents 6564544576b9
children
comparison
equal deleted inserted replaced
218:934608d4fcba 219:8341f2494b3f
12 return decorated 12 return decorated
13 return decorator 13 return decorator
14 14
15 class basetest(unittest.TestCase): 15 class basetest(unittest.TestCase):
16 def setUp(self): 16 def setUp(self):
17 os.environ['LANG'] = os.environ['LC_ALL'] = os.environ['LANGUAGE'] = 'C'
18 os.environ["EMAIL"] = "Foo Bar <foo.bar@example.com>"
19 os.environ['CDPATH'] = ''
20 os.environ['COLUMNS'] = '80'
21 os.environ['GREP_OPTIONS'] = ''
22 os.environ['http_proxy'] = ''
23
24 os.environ["HGEDITOR"] = sys.executable + ' -c "import sys; sys.exit(0)"'
25 os.environ["HGMERGE"] = "internal:merge"
26 os.environ["HGUSER"] = "test"
27 os.environ["HGENCODING"] = "ascii"
28 os.environ["HGENCODINGMODE"] = "strict"
29 tmpdir = tempfile.mkdtemp('', 'python-hglib.')
30 os.environ["HGTMP"] = os.path.realpath(tmpdir)
31 os.environ["HGRCPATH"] = os.pathsep
32
17 self._testtmp = os.environ["TESTTMP"] = os.environ["HOME"] = \ 33 self._testtmp = os.environ["TESTTMP"] = os.environ["HOME"] = \
18 os.path.join(os.environ["HGTMP"], self.__class__.__name__) 34 os.path.join(os.environ["HGTMP"], self.__class__.__name__)
19 35
20 self.clients = [] 36 self.clients = []
21 self._oldopen = hglib.client.hgclient.open 37 self._oldopen = hglib.client.hgclient.open
35 hglib.client.hgclient.open = self._oldopen 51 hglib.client.hgclient.open = self._oldopen
36 for client in self.clients: 52 for client in self.clients:
37 if client.server is not None: 53 if client.server is not None:
38 client.close() 54 client.close()
39 os.chdir('..') 55 os.chdir('..')
56
40 try: 57 try:
41 shutil.rmtree(self._testtmp) 58 shutil.rmtree(self._testtmp, ignore_errors=True)
42 except AttributeError: 59 except AttributeError:
43 pass # if our setUp was overriden 60 pass # if our setUp was overriden
44 61
45 def append(self, path, *args): 62 def append(self, path, *args):
46 f = open(path, 'ab') 63 f = open(path, 'ab')