##// END OF EJS Templates
run-tests: add docstrings
Gregory Szorc -
r21536:92a6b16c default
parent child Browse files
Show More
@@ -433,6 +433,10 b' class Test(unittest.TestCase):'
433 433 os.remove(self.errpath)
434 434
435 435 def run(self, result):
436 """Run this test and report results against a TestResult instance."""
437 # This function is extremely similar to unittest.TestCase.run(). Once
438 # we require Python 2.7 (or at least its version of unittest), this
439 # function can largely go away.
436 440 self._result = result
437 441 result.startTest(self)
438 442 try:
@@ -573,6 +577,12 b' class Test(unittest.TestCase):'
573 577 self._aborted = True
574 578
575 579 def _getreplacements(self):
580 """Obtain a mapping of text replacements to apply to test output.
581
582 Test output needs to be normalized so it can be compared to expected
583 output. This function defines how some of that normalization will
584 occur.
585 """
576 586 r = [
577 587 (r':%s\b' % self._startport, ':$HGPORT'),
578 588 (r':%s\b' % (self._startport + 1), ':$HGPORT1'),
@@ -590,6 +600,7 b' class Test(unittest.TestCase):'
590 600 return r
591 601
592 602 def _getenv(self):
603 """Obtain environment variables to use during test execution."""
593 604 env = os.environ.copy()
594 605 env['TESTTMP'] = self._testtmp
595 606 env['HOME'] = self._testtmp
@@ -625,7 +636,7 b' class Test(unittest.TestCase):'
625 636 return env
626 637
627 638 def _createhgrc(self, path):
628 # create a fresh hgrc
639 """Create an hgrc file for this test."""
629 640 hgrc = open(path, 'w')
630 641 hgrc.write('[ui]\n')
631 642 hgrc.write('slash = True\n')
@@ -1321,6 +1332,7 b' class TestRunner(object):'
1321 1332 Tests rely on a lot of state. This object holds it for them.
1322 1333 """
1323 1334
1335 # Programs required to run tests.
1324 1336 REQUIREDTOOLS = [
1325 1337 os.path.basename(sys.executable),
1326 1338 'diff',
@@ -1331,6 +1343,7 b' class TestRunner(object):'
1331 1343 'sed',
1332 1344 ]
1333 1345
1346 # Maps file extensions to test class.
1334 1347 TESTTYPES = [
1335 1348 ('.py', PythonTest),
1336 1349 ('.t', TTest),
@@ -1578,8 +1591,8 b' class TestRunner(object):'
1578 1591 pass
1579 1592
1580 1593 def _usecorrectpython(self):
1581 # Some tests run the Python interpreter. They must use the
1582 # same interpreter or bad things will happen.
1594 """Configure the environment to use the appropriate Python in tests."""
1595 # Tests must use the same interpreter as us or bad things will happen.
1583 1596 pyexename = sys.platform == 'win32' and 'python.exe' or 'python'
1584 1597 if getattr(os, 'symlink', None):
1585 1598 vlog("# Making python executable in test path a symlink to '%s'" %
@@ -1612,6 +1625,10 b' class TestRunner(object):'
1612 1625 print "WARNING: Cannot find %s in search path" % pyexename
1613 1626
1614 1627 def _installhg(self):
1628 """Install hg into the test environment.
1629
1630 This will also configure hg with the appropriate testing settings.
1631 """
1615 1632 vlog("# Performing temporary installation of HG")
1616 1633 installerrs = os.path.join("tests", "install.err")
1617 1634 compiler = ''
@@ -1721,6 +1738,7 b' class TestRunner(object):'
1721 1738 return self._hgpath
1722 1739
1723 1740 def _outputcoverage(self):
1741 """Produce code coverage output."""
1724 1742 vlog('# Producing coverage report')
1725 1743 os.chdir(self._pythondir)
1726 1744
@@ -1752,8 +1770,7 b' class TestRunner(object):'
1752 1770 return None
1753 1771
1754 1772 def _checktools(self):
1755 # Before we go any further, check for pre-requisite tools
1756 # stuff from coreutils (cat, rm, etc) are not tested
1773 """Ensure tools required to run tests are present."""
1757 1774 for p in self.REQUIREDTOOLS:
1758 1775 if os.name == 'nt' and not p.endswith('.exe'):
1759 1776 p += '.exe'
General Comments 0
You need to be logged in to leave comments. Login now