Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #64088

Re: Is it possible to get string from function?

Newsgroups comp.lang.python
Date 2014-01-16 08:29 -0800
References <lb86kj$993$1@ger.gmane.org> <mailman.5582.1389870171.18130.python-list@python.org>
Message-ID <06aa0ac8-dc0c-4c6a-a001-6c97230e00a5@googlegroups.com> (permalink)
Subject Re: Is it possible to get string from function?
From Roy Smith <roy@panix.com>

Show all headers | View raw


On Thursday, January 16, 2014 5:59:42 AM UTC-5, Albert-Jan Roskam wrote:

> 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")
> 
>     def test_b(self):
>         self.unique_value("large_value", "bar")  # oh no, a duplicate! 
> 
>     def test_c(self):
>         self.unique_value("another_large_value", "blah")

Although I didn't state it in my original post, we run these tests under nose in multi-process mode.  Each process would have its own copy of the receipts dictionary.

Yes, I know I can force all the tests in a class to be in the same process, but these are some of the slower tests in our suite, so we *want* them to run in parallel.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: Is it possible to get string from function? Albert-Jan Roskam <fomcl@yahoo.com> - 2014-01-16 02:59 -0800
  Re: Is it possible to get string from function? Roy Smith <roy@panix.com> - 2014-01-16 08:29 -0800

csiph-web