I personally don't see any benefit in this approach. By definition,
unittests should be independent, so the order argument suggests a
deeper issue.  What's your use case ?<br><br>
Quentin<br><br><div class="gmail_quote">On Fri, May 23, 2008 at 11:36 AM, Antoon Pardon <<a href="mailto:apardon@forel.vub.ac.be">apardon@forel.vub.ac.be</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Some time ago I asked whether is would be possible that unittest would<br>
perform the test in order of appearence in the file.<br>
<br>
The answers seemed to be negative. Since I really would like this<br>
behaviour I took the trouble of looking throught the source and<br>
I think I found a minor way to get this behaviour.<br>
<br>
Now my questions are:<br>
<br>
Are other people interrested in this behaviour?<br>
Does the following patch has a chance of being introduced in the<br>
standard python distribution?<br>
<br>
*** /usr/lib/python2.5/unittest.py      2008-04-17 16:26:37.000000000 +0200<br>
--- unittest.py 2008-05-23 11:19:57.000000000 +0200<br>
***************<br>
*** 570,575 ****<br>
--- 570,577 ----<br>
          """<br>
          def isTestMethod(attrname, testCaseClass=testCaseClass, prefix=self.testMethodPrefix):<br>
              return attrname.startswith(prefix) and callable(getattr(testCaseClass, attrname))<br>
+         def getlinenr(name):<br>
+             return getattr(testCaseClass, name).im_func.func_code.co_firstlineno<br>
          testFnNames = filter(isTestMethod, dir(testCaseClass))<br>
          for baseclass in testCaseClass.__bases__:<br>
              for testFnName in self.getTestCaseNames(baseclass):<br>
***************<br>
*** 577,582 ****<br>
--- 579,586 ----<br>
                      testFnNames.append(testFnName)<br>
          if self.sortTestMethodsUsing:<br>
              testFnNames.sort(self.sortTestMethodsUsing)<br>
+         else:<br>
+             testFnNames.sort(key=getlinenr)<br>
          return testFnNames<br>
<font color="#888888"><br>
<br>
--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></blockquote></div><br>