Patchwork run-tests: implement Test._testMethodName

login
register
mail settings
Submitter Pierre-Yves David
Date May 8, 2015, 6:12 p.m.
Message ID <3eccbad125c37db83952.1431108768@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/8977/
State Accepted
Headers show

Comments

Pierre-Yves David - May 8, 2015, 6:12 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1431065928 25200
#      Thu May 07 23:18:48 2015 -0700
# Node ID 3eccbad125c37db8395210ac714bbccf73c215b2
# Parent  17ba4ccd20b48511b3d06ab47fb1b2faf31410d7
run-tests: implement Test._testMethodName

This methods is needed internally by utilities like __repr__. I do not see any
harm in having it declared. Any actual attempt to use it to call a test would
crash, but at least random debug print in the test runner will no longer crash.

Another approach would have been to redefine the __repr__ function, but I think
it a good thing to have some respect for the base class API.
Augie Fackler - May 8, 2015, 6:19 p.m.
> On May 8, 2015, at 2:12 PM, Pierre-Yves David <pierre-yves.david@ens-lyon.org> wrote:
> 
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1431065928 25200
> #      Thu May 07 23:18:48 2015 -0700
> # Node ID 3eccbad125c37db8395210ac714bbccf73c215b2
> # Parent  17ba4ccd20b48511b3d06ab47fb1b2faf31410d7
> run-tests: implement Test._testMethodName

Looks fine to me, feel free to push it yourself since you're the main reviewer atm.

> 
> This methods is needed internally by utilities like __repr__. I do not see any
> harm in having it declared. Any actual attempt to use it to call a test would
> crash, but at least random debug print in the test runner will no longer crash.
> 
> Another approach would have been to redefine the __repr__ function, but I think
> it a good thing to have some respect for the base class API.

This is why inheritance is a bad idea ;)

> 
> diff --git a/tests/run-tests.py b/tests/run-tests.py
> --- a/tests/run-tests.py
> +++ b/tests/run-tests.py
> @@ -440,10 +440,15 @@ class Test(unittest.TestCase):
>             self._refout = f.read().splitlines(True)
>             f.close()
>         else:
>             self._refout = []
> 
> +    # needed to get base class __repr__ running
> +    @property
> +    def _testMethodName(self):
> +        return self.name
> +
>     def __str__(self):
>         return self.name
> 
>     def shortDescription(self):
>         return self.name
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Pierre-Yves David - May 8, 2015, 7:40 p.m.
On 05/08/2015 11:19 AM, Augie Fackler wrote:
>
>> On May 8, 2015, at 2:12 PM, Pierre-Yves David <pierre-yves.david@ens-lyon.org> wrote:
>>
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david@fb.com>
>> # Date 1431065928 25200
>> #      Thu May 07 23:18:48 2015 -0700
>> # Node ID 3eccbad125c37db8395210ac714bbccf73c215b2
>> # Parent  17ba4ccd20b48511b3d06ab47fb1b2faf31410d7
>> run-tests: implement Test._testMethodName
>
> Looks fine to me, feel free to push it yourself since you're the main reviewer atm.

pushed to the clowncopter.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -440,10 +440,15 @@  class Test(unittest.TestCase):
             self._refout = f.read().splitlines(True)
             f.close()
         else:
             self._refout = []
 
+    # needed to get base class __repr__ running
+    @property
+    def _testMethodName(self):
+        return self.name
+
     def __str__(self):
         return self.name
 
     def shortDescription(self):
         return self.name