Anonymous committed 481196c

issue 20: docstrings for all peformance plugin hooks

  • Participants
  • Parent commits 552f6e6
  • Branches 20-performance-plugin

Comments (0)

Files changed (2)

File functional_tests/

         assert 'perf_method (test_perf.PerformanceTest)' in self.output
         assert 'test_perf.perf_function' in self.output
-        assert 'Ran 10 tests in' in self.output
+        assert 'Ran 10 tests in' in self.output

File nose/plugins/

         self._stopTime = defaultdict(list)
     def options(self, parser, env=os.environ):
+        """Setup plugin options
+        """
                           "specified by ITERS [NOSE_PERFORMANCE_ITERS]")
     def configure(self, options, config):
+        """Configure plugin
+        """
         Plugin.configure(self, options, config)
         self.iters = options.iters
     def wantFunction(self, function):
+        """This plugin wants all functions that start with 'perf'
+        """
         return function.__name__.startswith('perf')
     def wantMethod(self, method):
+        """This plugin wants all methods that start with 'perf'
+        """
         return method.__name__.startswith('perf')
     def startTest(self, test):
+        """Record the start time for each test
+        """
     def stopTest(self, test):
+        """Record the stop time for each test
+        """
     def loadTestsFromNames(self, names, module=None):
         def iterated():
             for name in names:      
                 for test in loader.loadTestsFromName(name, module=module):
-                    print self.iters
                     for iter_ in range(self.iters):
                         yield test
         return (loader.suiteClass(iterated), [])
         self.loader = loader
     def report(self, stream):
+        """Write the performance report to a stream
+        """
         stream.write('-' * 70 + '\n')
         stream.write('Test Name\tMin time\tAvg time\tMax time\n')
-        for test in self._startTime:
+        for test in sorted(self._startTime):
             timeTaken = [(stop-start) for (stop, start) in 
                             zip(self._stopTime[test], self._startTime[test])]
             avgTimeTaken = sum(timeTaken)/len(timeTaken)