Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #64084
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Subject | Re: Is it possible to get string from function? |
| Date | 2014-01-16 15:50 +0100 |
| Organization | None |
| References | <lb86kj$993$1@ger.gmane.org> <1389869982.38511.YahooMailBasic@web163803.mail.gq1.yahoo.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5588.1389883815.18130.python-list@python.org> (permalink) |
Albert-Jan Roskam wrote:
> On Thu, 1/16/14, Peter Otten <__peter__@web.de> wrote:
>> class Foo(unittest.TestCase):
>> @unique_receipt("foo")
>> def test_t1(self, RECEIPT):
>> pass
> Very cool approach. Question, though: what would be wrong
> with the following approach:
>
>
> import unittest
>
> class Test(unittest.TestCase):
>
> receipts = {}
>
> def unique_value(self, k, v):
> assert Test.receipts.get(k) is None, "Duplicate: %s" % v
> Test.receipts[k] = v
>
> def test_a(self):
> self.unique_value("large_value", "foo")
Nothing.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Is it possible to get string from function? Peter Otten <__peter__@web.de> - 2014-01-16 15:50 +0100
csiph-web