PEP8 for long method's name [duplicate]
Asked Answered
A

1

6

What is the PEP8 correct way for long method's name? I have a unit test with a self-describing method:

def success_if_buying_price_item_when_participating_and_progression_is_100_percent(self):

But unfortunately this (too long?) method reaches the 80 characters line limit.

Should I rename it and add a description in code or there is an other way?

Amoretto answered 14/11, 2013 at 17:56 Comment(9)
You can break lines up as described in this other SO Post. #2071184Truant
That name says to me "this method is doing something far too special-purpose. It should be generalized."Blus
"Should I rename it" -- Yes. "add a description in code" -- This is what docstrings are for.Fence
For the love of whatever it is that you love, please rename itIterative
Ok, I upvoted anyone saying you should rename it because it was such a fun, BUT this is a unittest method, and I've written way longer unittest method names. That's part of the fun too <g>Caritacaritas
This is the reason why I asked for this specific case... but since every one seems to agree, I'm looking for a new name :)Amoretto
im curious to what name you came up with. If you did go with a shorter name, you would have multiple tests with almost similar and conflicting names. In the case of test failures and looking at the generated report, how do you quickly know what test failed and why?Questioning
I did not rename it because test names are often used as-is in report as you stated. And it felt worthless to try to fix that non-issue which is very test specific anyway...Amoretto
Also try adding description in the assertion code, like self.assertTrue(condition, "description comes here"). This will allow having some explanation in the CI pipeline logs.Plemmons
I
25

Should I rename it and add a description in code or there is an other way?

Yes, rename it and add a description. This code is dangerous, one could fall from its chair while another could have a heart attack. Please, rename that ASAP, you don't want to feel responsible.

Isomorphism answered 14/11, 2013 at 18:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.