Anonymous avatar Anonymous committed 481196c

issue 20: docstrings for all peformance plugin hooks

Comments (0)

Files changed (2)

functional_tests/test_performance_plugin.py

         
         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
+

nose/plugins/performance.py

         self._stopTime = defaultdict(list)
         
     def options(self, parser, env=os.environ):
+        """Setup plugin options
+        """
         parser.add_option("--performance",
                           action="store_true",
                           dest=self.enableOpt,
                           "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
+        """
         self._startTime[str(test)].append(time.time())
     
     def stopTest(self, test):
+        """Record the stop time for each test
+        """
         self._stopTime[str(test)].append(time.time())
 
     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)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.