[Python-Dev] PEP: Consolidating names and classes in the unittest
module (updated 2008-07-15) (original) (raw)
Jonathan Lange jml at mumak.net
Tue Jul 15 04🔞26 CEST 2008
- Previous message: [Python-Dev] PEP: Consolidating names and classes in the `unittest`module (updated 2008-07-15)
- Next message: [Python-Dev] PEP: Consolidating names and classes in the `unittest`module (updated 2008-07-15)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, Jul 15, 2008 at 12:06 PM, Raymond Hettinger <python at rcn.com> wrote:
setup(…)
ReplacessetUp(…)
. .
teardown(…)
ReplacestearDown(…)
Am I the only one who finds this sort of excessive pep-8 underscoring to be horrorific? Nobody I know spells setup and teardown as two words. I dread using the module with these new names.
Hi,
My name's Jonathan, and I spell "set up" as "set up" and "tear down" as "tear down".
It's not going to be easy to remember where they are used (ie. isinstance is still isinstance but isset is now isset). Go figure.
Yes, guessability via consistency is the important thing here.
failifalmostequal Another thought is that test suite code is going to get seriously crunched when the new, longer method names meet the 78/80 column pep 8 restrictions. class TestMisc(unittest.testcase): def lostfourspacesherealready(self): self.failifalmostequal('were already on the 34th column before' 'writing anything substantive', self.testedobject.testedmethod(arg1, arg2 + arg3, arg4) # Imagine typing and line wrapping dozens more tests like this Are there any ideas for some short, pithy, mnemonic names that are self-explantory and not full of underscores; something that wouldn't suck to type hundreds of times in a good test module? IMO, the current names are already too long.
Well, "assert_" is strictly shorter than "fail_unless_".
* Explicit is better than implicit: Don't forgot the opposing forces: Beautiful is better than ugly. Readability counts. These are especially important for the unittest module. When I'm making tests, I have to type self.verylongmethodname so many times it isn't funny. It's easy to just stop writing tests when you get tired of it. Long api names with underscores are a disincentive (IMO).
I find underscores easier to read—I suspect this will vary from person to person. Typing isn't an issue since I use an auto-complete function in my editor.
jml
- Previous message: [Python-Dev] PEP: Consolidating names and classes in the `unittest`module (updated 2008-07-15)
- Next message: [Python-Dev] PEP: Consolidating names and classes in the `unittest`module (updated 2008-07-15)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]