Is it possible to get string from function?
Roy Smith
roy at panix.com
Thu Jan 16 11:29:36 EST 2014
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.
More information about the Python-list
mailing list