Merge lp:~jml/testresources/tests-meaning-cleanup into lp:~lifeless/testresources/trunk
- tests-meaning-cleanup
- Merge into trunk
Status: | Merged |
---|---|
Merge reported by: | Jonathan Lange |
Merged at revision: | 18 |
Proposed branch: | lp:~jml/testresources/tests-meaning-cleanup |
Merge into: | lp:~lifeless/testresources/trunk |
To merge this branch: | bzr merge lp:~jml/testresources/tests-meaning-cleanup |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jonathan Lange (community) | Abstain | ||
Robert Collins | Pending | ||
Review via email: mp+767@code.launchpad.net |
Commit message
Description of the change
Robert Collins (lifeless) wrote : | # |
Jonathan Lange (jml) wrote : | # |
On Thu, Aug 21, 2008 at 2:57 PM, Robert Collins
<email address hidden> wrote:
> As I don't have a mail to reply to, I've copied the lp page here and
> marked replies with '*****'
>
> Where I haven't said anything, its good in principle.
>
> Once we're agreed conceptually I'd do an actual diff review.
>
> ----
>
> Hey Rob,
>
> I've done a *lot* of hacking over the weekend. I got into the zone a
> bit,
> which meant that I didn't really break the work up as well as I could
> have.
>
> The diff is big -- 1800+ lines -- so it might be easier for you to just
> look
> over the new codebase.
>
> My changes are broken down below. This letter might be converted into a
> NEWS
> file some day.
>
>
> LICENSE | 19
>
> Move the copyright statements from all over the code into a top-level
> LICENSE
> file. Almost every file was affected by the move, so I won't mention it
> in
> their summaries.
>
> The license is still GPL v2 or better. Copyright is Robert Collins
> 2005-2008,
> except for priodict and dijkstra. I've filled in information about those
> last
> two as best as I can without Internet.
>
> ***** Please don't do this, best practice for the GPL is the
> header-per-file as I had, and as bzr (for example) does. The LICENCE
> file also fails to reference COPYING which is the actual copyright
> licence.
>
OK. I'll revert this change, and if necessary bring the code inline
with http://
>
>
> lib/testresourc
>
> A lot of stuff changed here, obviously.
> - Renamed OptimisingTestSuite to OptimizingTestS
>
> **** Eep, now I see it, I'm more pro UK spelling than being ambivalent,
> I can deal, but ugh.
>
:)
> - Got rid of all the classmethod stuff on TestResource. Now it works
> much more
> like a normal Python object.
> - Renamed ResourcedTestCa
> - Renamed _makeResource to makeResource.
> - Renamed setResource to _setResource.
>
> **** This seems inconsistent, why make that one method private when the
> general thrust is making things more public?
>
The thrust is making the bits that people are supposed to *use*
public, and making the bits that are just there to reduce code
duplication private.
As best as I could tell _setResource has no reason to be public. In
fact, I was tempted to remove it at one point.
> - Renamed _cleanResource to cleanResource.
> - Moved a bunch of stuff out of OptimizingTestSuite into top-level
> functions.
> The goal here was to make things more testable.
>
> **** I'll need to look at the details, unless they are reusable
> fragments I'm not sure that this is better.
>
The functions are:
- cost_of_
- switch(
- split_by_
In this light, I think the first two should be made methods on
OptimizingTestSuite (I can imagine someone wanting to override them).
I can probably be persuaded to think the same thing about
split_by_resources, which splits 'tests' into 'tests that use
resources' and 'tests that don't'.
> - Renamed adsorbSuite to flatAddTest.
>
> **** Why? (if the intent is the same, but you want an addTest in the
> ...
Robert Collins (lifeless) wrote : | # |
On Thu, 2008-08-21 at 08:33 +0000, Jonathan Lange wrote:
> > LICENSE | 19
> >
> > Move the copyright statements from all over the code into a top-level
> > LICENSE
> > file. Almost every file was affected by the move, so I won't mention it
> > in
> > their summaries.
> >
> > The license is still GPL v2 or better. Copyright is Robert Collins
> > 2005-2008,
> > except for priodict and dijkstra. I've filled in information about those
> > last
> > two as best as I can without Internet.
> >
> > ***** Please don't do this, best practice for the GPL is the
> > header-per-file as I had, and as bzr (for example) does. The LICENCE
> > file also fails to reference COPYING which is the actual copyright
> > licence.
> >
>
> OK. I'll revert this change, and if necessary bring the code inline
> with http://
It should have been inline before; please just put it back the way it
was; I'd rather not have copyright changes that are dubious in the
history at all in fact - you probably need to branch from before these
changes and replay patches across.
I'd be happy to review a separate branch discussing copyright changes
though, but lets not conflate things.
-Rob
--
GPG key available at: <http://
Jonathan Lange (jml) wrote : | # |
On Fri, Aug 22, 2008 at 10:45 AM, Robert Collins
<email address hidden> wrote:
> On Thu, 2008-08-21 at 08:33 +0000, Jonathan Lange wrote:
>
>> > LICENSE | 19
>> >
>> > Move the copyright statements from all over the code into a top-level
>> > LICENSE
>> > file. Almost every file was affected by the move, so I won't mention it
>> > in
>> > their summaries.
>> >
>> > The license is still GPL v2 or better. Copyright is Robert Collins
>> > 2005-2008,
>> > except for priodict and dijkstra. I've filled in information about those
>> > last
>> > two as best as I can without Internet.
>> >
>> > ***** Please don't do this, best practice for the GPL is the
>> > header-per-file as I had, and as bzr (for example) does. The LICENCE
>> > file also fails to reference COPYING which is the actual copyright
>> > licence.
>> >
>>
>> OK. I'll revert this change, and if necessary bring the code inline
>> with http://
>
> It should have been inline before; please just put it back the way it
> was; I'd rather not have copyright changes that are dubious in the
> history at all in fact - you probably need to branch from before these
> changes and replay patches across.
>
> I'd be happy to review a separate branch discussing copyright changes
> though, but lets not conflate things.
>
Sure. Will do.
jml
- 65. By Jonathan Lange
-
More refactoring
- 78. By Jonathan Lange
-
Add a NEWS file listing the changes.
- 79. By Jonathan Lange
-
Rename flatAddTest to addTestFlat.
- 80. By Jonathan Lange
-
Move cost_of_switching and switch back into OptimizingTestS
uite. - 81. By Jonathan Lange
-
Update NEWS.
Jonathan Lange (jml) wrote : | # |
On Fri, Aug 22, 2008 at 10:45 AM, Robert Collins
<email address hidden> wrote:
> On Thu, 2008-08-21 at 08:33 +0000, Jonathan Lange wrote:
>
>> > LICENSE | 19
>> >
>> > Move the copyright statements from all over the code into a top-level
>> > LICENSE
>> > file. Almost every file was affected by the move, so I won't mention it
>> > in
>> > their summaries.
>> >
>> > The license is still GPL v2 or better. Copyright is Robert Collins
>> > 2005-2008,
>> > except for priodict and dijkstra. I've filled in information about those
>> > last
>> > two as best as I can without Internet.
>> >
>> > ***** Please don't do this, best practice for the GPL is the
>> > header-per-file as I had, and as bzr (for example) does. The LICENCE
>> > file also fails to reference COPYING which is the actual copyright
>> > licence.
>> >
>>
>> OK. I'll revert this change, and if necessary bring the code inline
>> with http://
>
> It should have been inline before; please just put it back the way it
> was; I'd rather not have copyright changes that are dubious in the
> history at all in fact - you probably need to branch from before these
> changes and replay patches across.
>
> I'd be happy to review a separate branch discussing copyright changes
> though, but lets not conflate things.
I've pushed up a new version that no longer has the license changes
and makes the changes I agreed to above.
I'm looking forward to hearing your reply.
jml
Robert Collins (lifeless) wrote : | # |
* testresources now depends on pyunit3k. You can still use
testresources
without using pyunit3k directly. (Jonathan Lange)
Thats not clear. Do you mean 'testresources needs pyunit3k to run its
own test suite'. Or 'if you use testresources you need to have pyunit3k
too.
* Calling finishedWith on a dirty resource now cleans that resource.
(Jonathan Lange)
It already did that; I'm not sure why this is NEWS :). Specifically
though, it actually resets it if its dirty and still in use.
I don't really like addTestFlat - it doesn't encapsulate the different
behaviour enough. adsorbSuite did. Also please put Optimise back as the
spelling. Both are clear, but Optimise is better English.
One of the points of SampleTestResource was to demonstrate how to create
a resource for users of the library. We need to reintroduce that
demonstration. This could be a doc file, part of README, whatever.
With the change to instance methods, I think make() and clean() would be
better method names rather than makeResource() and cleanResource().
You've left the copyright munging change in README - it too needs
reverting.
+
+ XXX - that last sentence needs some unpacking, I think. -- jml
+
The sentence that needs unpacking- Its saying that if you add everything
to a single OTS, you get global optimisation. Or you could use several
smaller OTSs.
I think your changes should be (c) You, or alternatively, you can assign
to me. I don't have an opinion as to whats better.
Files you edit, you should assert (c) on by adding a line appropriately.
+* It should be possible to make copies of TestSuites in adsorbSuite,
keeping
+ the containing TestSuites but at a chosen granularity, so that all
tests in
+ the resulting suites have identical resource requirements and
allowing
+ optimisation to still occur.
+ XXX: Clarify with Robert.
Say that you have a similar suite to OptimisingTestS
a service to its contained tests. adsorbSuite should not flatten the
tests but instead keep that suite. (Another reason addTestFlat doesn't
fit that well as a name).
Concrete example
input = SpecialSuite(
optimisedSuite.
pp optimisedSuite.
[SpecialSuite(
SpecialSuite(
The refactoring to 'self.switch' has a bug: an exception raised during
the switch will no longer leave the right resources setup on the OTS
object.
"p" before "r", or a line of VWS to separate stdlib and local imports.
+import random
+import pyunit3k
import testresources
-import testresources.tests
+from testresources import split_by_resources
There doesn't seem to be a test that the sortTests() method is invoked
anymore.
Why the move of test_suite from the top of
lib/testresourc
practice to have test_suite (or load_tests) at the top of test scripts,
to make them easy to find. Pls discuss.
The previous review was a conceptual one based on your mail, this was
based on the detailed code. With all of these points addressed I'll
merge it immediately.
-Rob
Jonathan Lange (jml) wrote : | # |
On Sat, Sep 6, 2008 at 5:27 PM, Robert Collins
<email address hidden> wrote:
>
> * testresources now depends on pyunit3k. You can still use
> testresources
> without using pyunit3k directly. (Jonathan Lange)
>
> Thats not clear. Do you mean 'testresources needs pyunit3k to run its
> own test suite'. Or 'if you use testresources you need to have pyunit3k
> too.
>
Rephrased to:
* testresources needs pyunit3k to run the testresources test suite. You
can still use testresources without using pyunit3k. (Jonathan Lange)
> * Calling finishedWith on a dirty resource now cleans that resource.
> (Jonathan Lange)
>
> It already did that; I'm not sure why this is NEWS :). Specifically
> though, it actually resets it if its dirty and still in use.
>
I see what happened here: I conflated two changes that were close
together in the logs.
I've added this entry to Internals:
* If calling finishedWith on a TestResource reduces its usage count to
zero, then the TestResource considers itself clean, i.e. _dirty is set
to True. (Jonathan Lange)
and have added this to a new bugfixes section:
* Calling getResource on a dirty resource now triggers a clean and re-make
of that resource. (Jonathan Lange)
See revisions 56 and 57 for more information.
> I don't really like addTestFlat - it doesn't encapsulate the different
> behaviour enough. adsorbSuite did. Also please put Optimise back as the
> spelling. Both are clear, but Optimise is better English.
>
I've changed it back to OptimisingTestS
a non-US spelling will create unnecessary friction for new users: both
with Americans and with people for whom English is a second language.
I also went away to do some research. Here's what I've found:
* The shorter OED lists "optimize" as the primary (and preferred) spelling.
* The dictionary introduction states that Oxford University Press
prefers "-ize" to "-ise".
* Fowler's has a list of words for which "-ise" is compulsory:
"optimise" is not included.
* In the general entry on "-ize, -ise in verbs", Fowler's says,
"The matter remains delicately balanced but unresolved. The primary
rule is that all words of the type authorize/
civilize/civilise, legalize/legalise may legitimately be spelt with
either -ize or -ise throughout the English-speaking world except in
America, where -ize is compulsory."
Regarding addTestFlat vs adsorbSuite, I don't see how absorbSuite
better describes the different behaviour. If I did, I probably
wouldn't have changed the name :)
As I understand it, we have two operations for adding tests: addTest
and METHOD (aka addTestFlat). The first preserves the structure of the
added tests, specifically by including any test suite wrappers. The
second flattens all structure. Perhaps you intend "adsorbSuite" to be
something more general than that, and that's why we're having trouble
fixing on a name.
> One of the points of SampleTestResource was to demonstrate how to create
> a resource for users of the library. We need to reintroduce that
> demonstration. This could be a doc file, part of README, whatever.
>
I've added this to doc/example...
- 82. By Jonathan Lange
-
Restore license text.
- 83. By Jonathan Lange
-
Corrections and clarifications to NEWS file.
- 84. By Jonathan Lange
-
Rename OptimizingTestSuite back to OptimisingTestS
uite. - 85. By Jonathan Lange
-
Update OptimisingTestSuite documentation.
- 86. By Jonathan Lange
-
Add a sample test resource.
- 87. By Jonathan Lange
-
Rename makeResource and cleanResource to make and clean.
- 88. By Jonathan Lange
-
Vertical whitespace.
- 89. By Jonathan Lange
-
80 cols
- 90. By Jonathan Lange
-
Add a test to confirm that sortTests is called.
Robert Collins (lifeless) wrote : | # |
On Sun, 2008-09-07 at 10:42 +0000, Jonathan Lange wrote:
> > * Calling finishedWith on a dirty resource now cleans that resource.
> > (Jonathan Lange)
> >
> > It already did that; I'm not sure why this is NEWS :). Specifically
> > though, it actually resets it if its dirty and still in use.
> >
>
> I see what happened here: I conflated two changes that were close
> together in the logs.
>
> I've added this entry to Internals:
> * If calling finishedWith on a TestResource reduces its usage count to
> zero, then the TestResource considers itself clean, i.e. _dirty is set
> to True. (Jonathan Lange)
>
> and have added this to a new bugfixes section:
> * Calling getResource on a dirty resource now triggers a clean and re-make
> of that resource. (Jonathan Lange)
>
> See revisions 56 and 57 for more information.
This is the pending merge's diff:
- def finishedWith(cls, resource):
- cls._uses -= 1
- if cls._uses == 0:
- cls._cleanResou
- cls._currentRes
- elif cls._dirty:
- cls._cleanResou
- cls.setResource()
- finishedWith = classmethod(
So I don't see what's changed - the prior behaviour was:
if it is no longer in use it is cleaned
otherwise if it is dirty it is reset
The new behaviour seems identical.
> > I don't really like addTestFlat - it doesn't encapsulate the different
> > behaviour enough. adsorbSuite did. Also please put Optimise back as the
> > spelling. Both are clear, but Optimise is better English.
> >
> Regarding addTestFlat vs adsorbSuite, I don't see how absorbSuite
> better describes the different behaviour. If I did, I probably
> wouldn't have changed the name :)
I am not enamoured of adsorbSuite; however addTestFlat is also not
really good - see the later discussion.
> > One of the points of SampleTestResource was to demonstrate how to create
> > a resource for users of the library. We need to reintroduce that
> > demonstration. This could be a doc file, part of README, whatever.
> >
>
> I've added this to doc/example.py, and added a reference to it in the README.
>
> As an example, I think it could stand to be improved.
good examples > bad examples > no examples :)
> > +
> > + XXX - that last sentence needs some unpacking, I think. -- jml
> > +
> >
> > The sentence that needs unpacking- Its saying that if you add everything
> > to a single OTS, you get global optimisation. Or you could use several
> > smaller OTSs.
> >
>
> The two paragraphs now say:
>
> OptimisingTestSuite has a new method over normal TestSuites:
> addTestFlat(
> incorporates all of its tests directly into the OptimisingTestS
>
> Because the test suite does the optimisation, you can control the amount of
> optimising that takes place by adding more or fewer tests to a single
> OptimisingTestS
> getting global optimisation or you could use several smaller
> OptimisingTestS
These words are good, given the current adding behaviour.
> > I think your changes sho...
Jonathan Lange (jml) wrote : | # |
On Mon, Sep 8, 2008 at 8:33 AM, Robert Collins
<email address hidden> wrote:
> On Sun, 2008-09-07 at 10:42 +0000, Jonathan Lange wrote:
>
>
>> > * Calling finishedWith on a dirty resource now cleans that resource.
>> > (Jonathan Lange)
>> >
>> > It already did that; I'm not sure why this is NEWS :). Specifically
>> > though, it actually resets it if its dirty and still in use.
>> >
>>
>> I see what happened here: I conflated two changes that were close
>> together in the logs.
>>
>> I've added this entry to Internals:
>> * If calling finishedWith on a TestResource reduces its usage count to
>> zero, then the TestResource considers itself clean, i.e. _dirty is set
>> to True. (Jonathan Lange)
>>
>> and have added this to a new bugfixes section:
>> * Calling getResource on a dirty resource now triggers a clean and re-make
>> of that resource. (Jonathan Lange)
>>
>> See revisions 56 and 57 for more information.
>
> This is the pending merge's diff:
> - def finishedWith(cls, resource):
> - cls._uses -= 1
> - if cls._uses == 0:
> - cls._cleanResou
> - cls._currentRes
> - elif cls._dirty:
> - cls._cleanResou
> - cls.setResource()
> - finishedWith = classmethod(
>
>
> So I don't see what's changed - the prior behaviour was:
> if it is no longer in use it is cleaned
> otherwise if it is dirty it is reset
>
> The new behaviour seems identical.
>
Note that the finishedWith above doesn't change the value of
self._dirty when _uses is 0. In the new version, self._dirty is set to
False if _uses is 0. That is all.
My other change was to getResources:
Old code:
def getResource(cls):
if not hasattr(cls, "_uses"):
if cls._uses == 0:
cls._uses += 1
return cls._currentRes
getResource = classmethod(
New code:
def getResource(self):
if self._uses == 0:
elif self._dirty:
self._uses += 1
return self._currentRe
Note that the new code has an 'if self._dirty' branch.
>> > I don't really like addTestFlat - it doesn't encapsulate the different
>> > behaviour enough. adsorbSuite did. Also please put Optimise back as the
>> > spelling. Both are clear, but Optimise is better English.
>> >
>
>> Regarding addTestFlat vs adsorbSuite, I don't see how absorbSuite
>> better describes the different behaviour. If I did, I probably
>> wouldn't have changed the name :)
>
> I am not enamoured of adsorbSuite; however addTestFlat is also not
> really good - see the later discussion.
>
OK. Let's thrash this one out via voce.
>> > I think your changes should be (c) You, or alternatively, you can assign
>> > to me. I don't have an opinion as to whats better.
>> >
>> > Files you edit, you should assert (c) on by adding a line appropriately.
>> >
>> > +* It should be possible to make copies of TestSuites in ads...
- 91. By Jonathan Lange
-
Clarify TODO item that I found unclear.
- 92. By Jonathan Lange
-
Move test_suite definitions to the top of test files, because lifeless
likes it that way.
Robert Collins (lifeless) wrote : | # |
On Sun, 2008-09-07 at 23:03 +0000, Jonathan Lange wrote:
> On Mon, Sep 8, 2008 at 8:33 AM, Robert Collins
> <email address hidden> wrote:
> > On Sun, 2008-09-07 at 10:42 +0000, Jonathan Lange wrote:
> >
> >
> >> > * Calling finishedWith on a dirty resource now cleans that resource.
> >> > (Jonathan Lange)
> >> >
> >> > It already did that; I'm not sure why this is NEWS :). Specifically
> >> > though, it actually resets it if its dirty and still in use.
> >> >
> >>
> >> I see what happened here: I conflated two changes that were close
> >> together in the logs.
> >>
> >> I've added this entry to Internals:
> >> * If calling finishedWith on a TestResource reduces its usage count to
> >> zero, then the TestResource considers itself clean, i.e. _dirty is set
> >> to True. (Jonathan Lange)
> >>
> >> and have added this to a new bugfixes section:
> >> * Calling getResource on a dirty resource now triggers a clean and re-make
> >> of that resource. (Jonathan Lange)
> >>
> >> See revisions 56 and 57 for more information.
> >
> > This is the pending merge's diff:
> > - def finishedWith(cls, resource):
> > - cls._uses -= 1
> > - if cls._uses == 0:
> > - cls._cleanResou
> > - cls._currentRes
> > - elif cls._dirty:
> > - cls._cleanResou
> > - cls.setResource()
> > - finishedWith = classmethod(
> >
> >
> > So I don't see what's changed - the prior behaviour was:
> > if it is no longer in use it is cleaned
> > otherwise if it is dirty it is reset
> >
> > The new behaviour seems identical.
> >
>
> Note that the finishedWith above doesn't change the value of
> self._dirty when _uses is 0. In the new version, self._dirty is set to
> False if _uses is 0. That is all.
Ah yes. Ok, that certainly benefits by being documented. (Though the
dirty flag is irrelevant for an unused resource :)). That should be one
NEWS item though, not two ?
> >> > I don't really like addTestFlat - it doesn't encapsulate the different
> >> > behaviour enough. adsorbSuite did. Also please put Optimise back as the
> >> > spelling. Both are clear, but Optimise is better English.
> >> >
> >
> >> Regarding addTestFlat vs adsorbSuite, I don't see how absorbSuite
> >> better describes the different behaviour. If I did, I probably
> >> wouldn't have changed the name :)
> >
> > I am not enamoured of adsorbSuite; however addTestFlat is also not
> > really good - see the later discussion.
> >
>
> OK. Let's thrash this one out via voce.
> * We want to support adding other "special" test suites to
> OptimisingTestS
> services to its tests to an OptimisingTestS
> should not totally flatten the suite, but instead keep the suite, even if it
> changes the structure of the tests.
>
> e.g. addTest maintains the structure:
> >>> OptimisingTestS
> [SpecialSuite([a, b])]
>
> Currently, addTestFlat destroys all suite structure:
> >>> OptimisingTestS
Jonathan Lange (jml) wrote : | # |
On Mon, Sep 8, 2008 at 11:48 AM, Robert Collins
<email address hidden> wrote:
> On Sun, 2008-09-07 at 23:03 +0000, Jonathan Lange wrote:
>> On Mon, Sep 8, 2008 at 8:33 AM, Robert Collins
>> <email address hidden> wrote:
>> > On Sun, 2008-09-07 at 10:42 +0000, Jonathan Lange wrote:
>> >
>> >
>> >> > * Calling finishedWith on a dirty resource now cleans that resource.
>> >> > (Jonathan Lange)
>> >> >
>> >> > It already did that; I'm not sure why this is NEWS :). Specifically
>> >> > though, it actually resets it if its dirty and still in use.
>> >> >
>> >>
>> >> I see what happened here: I conflated two changes that were close
>> >> together in the logs.
>> >>
>> >> I've added this entry to Internals:
>> >> * If calling finishedWith on a TestResource reduces its usage count to
>> >> zero, then the TestResource considers itself clean, i.e. _dirty is set
>> >> to True. (Jonathan Lange)
>> >>
>> >> and have added this to a new bugfixes section:
>> >> * Calling getResource on a dirty resource now triggers a clean and re-make
>> >> of that resource. (Jonathan Lange)
>> >>
>> >> See revisions 56 and 57 for more information.
>> >
>> > This is the pending merge's diff:
>> > - def finishedWith(cls, resource):
>> > - cls._uses -= 1
>> > - if cls._uses == 0:
>> > - cls._cleanResou
>> > - cls._currentRes
>> > - elif cls._dirty:
>> > - cls._cleanResou
>> > - cls.setResource()
>> > - finishedWith = classmethod(
>> >
>> >
>> > So I don't see what's changed - the prior behaviour was:
>> > if it is no longer in use it is cleaned
>> > otherwise if it is dirty it is reset
>> >
>> > The new behaviour seems identical.
>> >
>>
>> Note that the finishedWith above doesn't change the value of
>> self._dirty when _uses is 0. In the new version, self._dirty is set to
>> False if _uses is 0. That is all.
>
> Ah yes. Ok, that certainly benefits by being documented. (Though the
> dirty flag is irrelevant for an unused resource :)). That should be one
> NEWS item though, not two ?
>
The second NEWS item is that if you do:
resource = resource_
resource_
resource = resource_
Then the second invocation of getResource will trigger a clean. This
is separate setting self._dirty on unused resources.
jml
Robert Collins (lifeless) wrote : | # |
On Mon, 2008-09-08 at 01:54 +0000, Jonathan Lange wrote:
>
> The second NEWS item is that if you do:
> resource = resource_
> resource_
> resource = resource_
>
> Then the second invocation of getResource will trigger a clean. This
> is separate setting self._dirty on unused resources.
Uhm. Something must have changed under the hood - some calling pattern
is different.
Certainly either what I had was broken, or I'd expect similar things to
preserve state appropriately as well.
-Rob
--
GPG key available at: <http://
Jonathan Lange (jml) wrote : | # |
On Mon, Sep 8, 2008 at 12:12 PM, Robert Collins
<email address hidden> wrote:
> On Mon, 2008-09-08 at 01:54 +0000, Jonathan Lange wrote:
>>
>> The second NEWS item is that if you do:
>> resource = resource_
>> resource_
>> resource = resource_
>>
>> Then the second invocation of getResource will trigger a clean. This
>> is separate setting self._dirty on unused resources.
>
> Uhm. Something must have changed under the hood - some calling pattern
> is different.
>
> Certainly either what I had was broken, or I'd expect similar things to
> preserve state appropriately as well.
>
I think the current trunk is broken: you'll notice that it doesn't
have any branch for 'if self._dirty'. Certainly, the 'getResource;
dirty; getResource' call pattern doesn't have any tests.
The test I added for this is 'testDirtyingRe
It's supplemented by testUsingTwiceM
testDirtyingWhe
discuss it when we are renaming addTestFlat.
jml
1 | === modified file 'lib/testresources/__init__.py' |
2 | --- lib/testresources/__init__.py 2008-08-17 07:19:40 +0000 |
3 | +++ lib/testresources/__init__.py 2008-08-17 07:33:54 +0000 |
4 | @@ -190,6 +190,9 @@ |
5 | """ |
6 | if self._uses == 0: |
7 | self._setResource() |
8 | + elif self._dirty: |
9 | + self.cleanResource(self._currentResource) |
10 | + self._setResource() |
11 | self._uses += 1 |
12 | return self._currentResource |
13 | |
14 | |
15 | === modified file 'lib/testresources/tests/test_test_resource.py' |
16 | --- lib/testresources/tests/test_test_resource.py 2008-08-17 07:19:40 +0000 |
17 | +++ lib/testresources/tests/test_test_resource.py 2008-08-17 07:33:54 +0000 |
18 | @@ -126,6 +126,15 @@ |
19 | resource_manager.finishedWith(resource) |
20 | self.assertEqual(1, resource_manager.cleans) |
21 | |
22 | + def testUsingTwiceMakesAndCleansTwice(self): |
23 | + resource_manager = MockResource() |
24 | + resource = resource_manager.getResource() |
25 | + resource_manager.finishedWith(resource) |
26 | + resource = resource_manager.getResource() |
27 | + resource_manager.finishedWith(resource) |
28 | + self.assertEqual(2, resource_manager.makes) |
29 | + self.assertEqual(2, resource_manager.cleans) |
30 | + |
31 | def testFinishedWithCallsCleanResourceOnceOnly(self): |
32 | resource_manager = MockResource() |
33 | resource = resource_manager.getResource() |
34 | @@ -166,6 +175,25 @@ |
35 | resource_manager.finishedWith(resource1) |
36 | self.assertEqual(2, resource_manager.cleans) |
37 | |
38 | + def testDirtyingResourceTriggersRemake(self): |
39 | + resource_manager = MockResource() |
40 | + resource = resource_manager.getResource() |
41 | + self.assertEqual(1, resource_manager.makes) |
42 | + resource_manager.dirtied(resource) |
43 | + resource_manager.getResource() |
44 | + self.assertEqual(1, resource_manager.cleans) |
45 | + self.assertEqual(2, resource_manager.makes) |
46 | + self.assertEqual(False, resource_manager._dirty) |
47 | + |
48 | + def testDirtyingWhenUnused(self): |
49 | + resource_manager = MockResource() |
50 | + resource = resource_manager.getResource() |
51 | + resource_manager.finishedWith(resource) |
52 | + resource_manager.dirtied(resource) |
53 | + self.assertEqual(1, resource_manager.makes) |
54 | + resource = resource_manager.getResource() |
55 | + self.assertEqual(2, resource_manager.makes) |
56 | + |
57 | |
58 | class TestSampleResource(pyunit3k.TestCase): |
59 |
- 93. By Jonathan Lange
-
Forgot to remove this.
- 94. By Jonathan Lange
-
Rollback rename of adsorbSuite.
- 95. By Jonathan Lange
-
Remove unclear / crazy TODO item.
Jonathan Lange (jml) wrote : | # |
addTestFlat is back to adsorbSuite, with the documented understanding that it'll be deprecated in favor of smarter addTest methods.
We've clarified the issue with tests.
Oh hey look I can vote on my own branch :)
James Henstridge (jamesh) wrote : | # |
> > Thats not clear. Do you mean 'testresources needs pyunit3k to run its
> > own test suite'. Or 'if you use testresources you need to have pyunit3k
> > too.
> >
>
> Rephrased to:
> * testresources needs pyunit3k to run the testresources test suite. You
> can still use testresources without using pyunit3k. (Jonathan Lange)
That doesn't appear to be true though. Right at the top of testresources/
Jonathan Lange (jml) wrote : | # |
Good point!
IIRC, Rob's requirement was that people shouldn't have to subclass pyunit3k stuff. I'll push up a revision which doesn't have the import and see what he thinks.
As I don't have a mail to reply to, I've copied the lp page here and
marked replies with '*****'
Where I haven't said anything, its good in principle.
Once we're agreed conceptually I'd do an actual diff review.
----
Hey Rob,
I've done a *lot* of hacking over the weekend. I got into the zone a
bit,
which meant that I didn't really break the work up as well as I could
have.
The diff is big -- 1800+ lines -- so it might be easier for you to just
look
over the new codebase.
My changes are broken down below. This letter might be converted into a
NEWS
file some day.
LICENSE | 19
Move the copyright statements from all over the code into a top-level
LICENSE
file. Almost every file was affected by the move, so I won't mention it
in
their summaries.
The license is still GPL v2 or better. Copyright is Robert Collins
2005-2008,
except for priodict and dijkstra. I've filled in information about those
last
two as best as I can without Internet.
***** Please don't do this, best practice for the GPL is the
header-per-file as I had, and as bzr (for example) does. The LICENCE
file also fails to reference COPYING which is the actual copyright
licence.
lib/testresour ces/__init_ _.py | 333 ++++++++-------
A lot of stuff changed here, obviously. uite.
- Renamed OptimisingTestSuite to OptimizingTestS
**** Eep, now I see it, I'm more pro UK spelling than being ambivalent,
I can deal, but ugh.
- Got rid of all the classmethod stuff on TestResource. Now it works se._resources to resources.
much more
like a normal Python object.
- Renamed ResourcedTestCa
- Renamed _makeResource to makeResource.
- Renamed setResource to _setResource.
**** This seems inconsistent, why make that one method private when the
general thrust is making things more public?
- Renamed _cleanResource to cleanResource.
- Moved a bunch of stuff out of OptimizingTestSuite into top-level
functions.
The goal here was to make things more testable.
**** I'll need to look at the details, unless they are reusable
fragments I'm not sure that this is better.
- Renamed adsorbSuite to flatAddTest.
**** Why? (if the intent is the same, but you want an addTest in the
name, I'd suffix addTests rather than prefixing, so in doc generation
its more visible).
I disabled the crazy intermittent test after having sussed out *why* it
was
intermittent (although not why *.pyc files had an effect).
**** expectFail please, rather than disable.
You'll also notice that I call instances of TestResource managers' .
'resource_
I couldn't think of anything better at the time.
**** That suggests ResourceManager rather than TestResource.
-Rob
-- www.robertcolli ns.net/ keys.txt>.
GPG key available at: <http://