From: Yann E. MORIN <yann.morin.1998@free.fr>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH] support/tests: allow properly indented config fragment
Date: Tue, 18 Jul 2017 21:58:44 +0200 [thread overview]
Message-ID: <20170718195844.GD2583@scaer> (raw)
In-Reply-To: <ec7f482c-c5e2-106e-0ad3-d7b65898bf1c@mind.be>
Arnout, All,
On 2017-07-18 21:55 +0200, Arnout Vandecappelle spake thusly:
> On 18-07-17 21:45, Yann E. MORIN wrote:
> > Arnout, All,
> >
> > On 2017-07-18 21:37 +0200, Arnout Vandecappelle spake thusly:
> [snip]
> >> I would do this in BRTest instead of down here, so that self.config contains a
> >> correct config file. In fact, I would do it in its constructor instead of in
> >> setUp(), so that it is done only once even if a class has two test functions.
> >
> > Meh, I have no real clue on how those class- or instance-scoped
> > variables play iwth each others... I think this is sad that we use
> > class-scoped config variable for the actual tests; they should be
> > instance-scoped instead, but that requires one to actually write an
> > __init__ function, so a classscoped is quicker to write.
> >
> > Be if we ever want to derive a Test class into another, then we'll have
> > issues I guess...
> >
> > But if I understand you correctly, you'd prefer (code elided for
> > brevity):
> >
> > class BRTest():
> > def __init__(self):
> > self.config = '\n'.join(map(str.lstrip, self.config.splitlines()))
> >
> > Right?
>
> Exactly.
>
> Note that this conveniently converts the class-scoped variable to an
> instance-scoped one (the reference on the right-hand side refers to the class
> variable, the reference on the left-hand side creates the instance variable).
> Still a big Meh for you, but at least after __init__ it feels natural.
Ack.
> >> I would also do it as a oneliner:
> >> self.config = '\n'.join(map(str.lstrip, self.config.splitlines()))
> >> but some people don't like oneliners :-)
> >
> > Well, I prefer it, because it is rather self-explanatory. But I could
> > not have wrote it myself (I did not know about map() ).
>
> TBH, nowadays Python people prefer the [ for ] construct, so
>
> self.config = '\n'.join([line.lstrip for line in self.config.splitlines()])
Ah, that was the construct I wanted to write, but for the sake of me, I
could not remeber the exact syntax... That's what I'll use, because it
is more pythonic (as you also noted).
> I'm still an old LISP guy so I know map() better :-)
LISP. Meh... A whole lot of insipid and stupid parentehses, that's all I
remember of it. ;-]
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
prev parent reply other threads:[~2017-07-18 19:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-15 22:49 [Buildroot] [PATCH] support/tests: allow properly indented config fragment Yann E. MORIN
2017-07-16 7:18 ` Thomas Petazzoni
2017-07-16 8:11 ` Yann E. MORIN
2017-07-18 19:37 ` Arnout Vandecappelle
2017-07-18 19:45 ` Yann E. MORIN
2017-07-18 19:55 ` Arnout Vandecappelle
2017-07-18 19:58 ` Yann E. MORIN [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170718195844.GD2583@scaer \
--to=yann.morin.1998@free.fr \
--cc=buildroot@busybox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox