derwiki-adroll / mock

Automatically exported from code.google.com/p/mock
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

mock class decorator? #31

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Seems to make sense now that class decorators made it into Python 2.6

Original issue reported on code.google.com by kon...@gmail.com on 10 Jun 2010 at 9:51

GoogleCodeExporter commented 9 years ago
What would mock do as a class decorator?

Original comment by fuzzyman on 10 Jun 2010 at 9:55

GoogleCodeExporter commented 9 years ago
it would wrap every test method in a testcase

Original comment by kon...@gmail.com on 10 Jun 2010 at 11:09

GoogleCodeExporter commented 9 years ago
Wrap every test method in a testcase? Eh? (In unittest all test methods become 
separate TestCase instances anyway.) What does that have to do with mock?

Do you mean patch as a class decorator, automatically wrapping a patch 
decorator round every test method instead of having to decorate them separately?

Original comment by fuzzyman on 10 Jun 2010 at 11:18

GoogleCodeExporter commented 9 years ago

Original comment by fuzzyman on 10 Jun 2010 at 11:19

GoogleCodeExporter commented 9 years ago
> Do you mean patch as a class decorator, automatically wrapping a patch 
decorator round every test method instead of having to decorate them separately?

Exactly :)

Original comment by kon...@gmail.com on 10 Jun 2010 at 11:22

GoogleCodeExporter commented 9 years ago
Right - so given your comment on issue 30 I think what you mean is to allow 
patch to work as a class decorator; the equivalent of patching every test 
method. That sounds like a good feature. Again, I would be open to patches 
(with tests and docs).

Want to help me maintain mock? There are lots of open issues here you could 
comment on...

Original comment by fuzzyman on 10 Jun 2010 at 11:24

GoogleCodeExporter commented 9 years ago
Sure, I'll get to it this evening.

Original comment by kon...@gmail.com on 10 Jun 2010 at 11:57

GoogleCodeExporter commented 9 years ago

Original comment by fuzzyman on 12 Jun 2010 at 10:58

GoogleCodeExporter commented 9 years ago
Test methods are unfortunately identified by the TestLoader.testMethodPrefix 
attribute. That means from a TestCase class you can't *tell* which methods will 
later be used as tests. 

For initial implementation we could recognise test methods as ones that start 
with 'test'. Maybe consider making it configurable as a feature request for 
future releases.

Original comment by fuzzyman on 12 Jun 2010 at 11:03

GoogleCodeExporter commented 9 years ago

Original comment by fuzzyman on 12 Jun 2010 at 11:22

GoogleCodeExporter commented 9 years ago

Original comment by kon...@gmail.com on 12 Jun 2010 at 12:49