--- testresources-0.1.orig/setup.py
+++ testresources-0.1/setup.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2.4
from distutils.core import setup
--- testresources-0.1.orig/test_all.py
+++ testresources-0.1/test_all.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2.4
# -*- Mode: python -*-
#
# Copyright (C) 2004 Canonical.com
--- testresources-0.1.orig/.bzr/inventory.weave
+++ testresources-0.1/.bzr/inventory.weave
@@ -0,0 +1,276 @@
+# bzr weave file v5
+i
+1 77204ff85090a6b941b6c37d460ee039878470da
+n robertc@robertcollins.net-20050904003259-a335a92fb647113f
+
+i 0
+1 dd0cb0b64faf061e812f65e13587a7370f9bffda
+n robertc@robertcollins.net-20050904004612-ed91f2dc7ad89cfe
+
+i 1
+1 e243f75a4ec00bbde437e56c7500af9c29d3182a
+n robertc@robertcollins.net-20050904005052-0fddf3e7c8d9fd3a
+
+i 2
+1 fe10dfe9dae9a914acdead7284712f602942d73e
+n robertc@robertcollins.net-20050904010922-869a537b81ebfb20
+
+i 3
+1 c8b9e01e82b754799fc5667a80722c9a60410fb6
+n robertc@robertcollins.net-20050904011543-fc1dc855cee3deaa
+
+i 4
+1 d1a852e2c2f57e251ae648dea4473d1e353e1318
+n robertc@robertcollins.net-20050904013507-2558f957d338d04b
+
+i 5
+1 927dd470f25e39ed24966ef9bb3f39ec8aefcdb1
+n robertc@robertcollins.net-20050904014403-6e8106d48aac2f09
+
+i 6
+1 b6cb71dce3454ba542d843ec9746423c1705e843
+n robertc@robertcollins.net-20050904071016-083acf76691fed70
+
+i 7
+1 b3c2b02676688212756d7d90ffb2673798a63f27
+n robertc@robertcollins.net-20050904072941-fa3cf56d8ea541a3
+
+i 8
+1 ddd14705c733a6edd11a44ea4513fe62e30197b1
+n robertc@robertcollins.net-20050904074811-ac5e82d554a018e3
+
+i 9
+1 0934f1409b5074332418df2fa1e8a11937351991
+n robertc@robertcollins.net-20050904080857-d3be838de97553dd
+
+i 10
+1 182817bc25fa7c4ce89cdffbde6d607695e8ff24
+n robertc@robertcollins.net-20050904081216-97a972a5a0611b74
+
+i 11
+1 03ba02a26750038fbdd5c793ea7f7e97a67f07a4
+n robertc@robertcollins.net-20050904092827-b5ed46068a9231ef
+
+i 12
+1 b9c9dcbd9c7cd0737a3c2e188d2b2c942c2dd610
+n robertc@robertcollins.net-20050904134722-5065a32e76d01b6e
+
+i 13
+1 4e7058cc3bed4fe16b0008c7ce7b96043df980e0
+n robertc@robertcollins.net-20050905073000-2a3738a209cd8085
+
+i 14
+1 4f746c9d366a409a65d6274fd0490255e809f699
+n robertc@robertcollins.net-20050911111209-ee5da49011cf936a
+
+i 15
+1 6bbe8043a40a9a20cad887af93063224b08c6a86
+n robertc@robertcollins.net-20060215013125-a9198a84b94012bb
+
+w
+{ 0
+.
+.
+.
+[ 1
+.
+] 1
+{ 1
+[ 3
+.
+}
+] 3
+{ 3
+[ 6
+.
+}
+] 6
+{ 6
+[ 7
+.
+}
+] 7
+{ 7
+[ 8
+.
+}
+] 8
+{ 8
+[ 14
+.
+}
+] 14
+{ 14
+.
+}
+.
+.
+[ 1
+.
+] 1
+{ 1
+[ 2
+.
+}
+] 2
+{ 2
+[ 3
+.
+}
+] 3
+{ 3
+[ 4
+.
+}
+] 4
+{ 4
+[ 5
+.
+}
+] 5
+{ 5
+[ 6
+.
+}
+] 6
+{ 6
+[ 7
+.
+}
+] 7
+{ 7
+[ 8
+.
+}
+] 8
+{ 8
+[ 9
+.
+}
+] 9
+{ 9
+[ 10
+.
+}
+] 10
+{ 10
+[ 11
+.
+}
+] 11
+{ 11
+[ 12
+.
+}
+] 12
+{ 12
+[ 13
+.
+] 13
+{ 13
+[ 15
+.
+}
+] 15
+{ 15
+.
+}
+.
+.
+}
+.
+[ 8
+.
+[ 1
+.
+] 1
+{ 1
+[ 2
+.
+] 2
+{ 2
+[ 7
+.
+}
+] 7
+{ 7
+.
+] 8
+{ 8
+.
+.
+[ 9
+.
+}
+] 9
+{ 9
+[ 10
+.
+}
+] 10
+{ 10
+[ 11
+.
+}
+] 11
+{ 11
+[ 12
+.
+}
+] 12
+{ 12
+[ 13
+.
+}
+] 13
+{ 13
+.
+}
+.
+}
+.
+}
+{ 2
+[ 3
+.
+}
+] 3
+{ 3
+[ 4
+.
+}
+] 4
+{ 4
+[ 5
+.
+}
+] 5
+{ 5
+[ 6
+.
+}
+] 6
+{ 6
+[ 7
+.
+}
+] 7
+{ 7
+[ 15
+.
+}
+] 15
+{ 15
+.
+}
+[ 16
+.
+,
+}
+] 16
+{ 16
+.
+.
+.
+}
+W
--- testresources-0.1.orig/.bzr/branch-format
+++ testresources-0.1/.bzr/branch-format
@@ -0,0 +1 @@
+Bazaar-NG branch, format 6
--- testresources-0.1.orig/.bzr/revision-store/93/robertc@robertcollins.net-20050904011543-fc1dc855cee3deaa
+++ testresources-0.1/.bzr/revision-store/93/robertc@robertcollins.net-20050904011543-fc1dc855cee3deaa
@@ -0,0 +1,6 @@
+
+let derived TestResources trivially reuse the reference counting facilities.
+
+
+
+
--- testresources-0.1.orig/.bzr/revision-store/42/robertc@robertcollins.net-20050905073000-2a3738a209cd8085
+++ testresources-0.1/.bzr/revision-store/42/robertc@robertcollins.net-20050905073000-2a3738a209cd8085
@@ -0,0 +1,6 @@
+
+save notes from last night
+
+
+
+
--- testresources-0.1.orig/.bzr/revision-store/b6/robertc@robertcollins.net-20050904092827-b5ed46068a9231ef
+++ testresources-0.1/.bzr/revision-store/b6/robertc@robertcollins.net-20050904092827-b5ed46068a9231ef
@@ -0,0 +1,6 @@
+
+optimise resource construction somewhat - not travelling salesman, just plain old dijkstra
+
+
+
+
--- testresources-0.1.orig/.bzr/revision-store/0c/robertc@robertcollins.net-20050904072941-fa3cf56d8ea541a3
+++ testresources-0.1/.bzr/revision-store/0c/robertc@robertcollins.net-20050904072941-fa3cf56d8ea541a3
@@ -0,0 +1,6 @@
+
+initial cut at adsorbSuite
+
+
+
+
--- testresources-0.1.orig/.bzr/revision-store/71/robertc@robertcollins.net-20050904004612-ed91f2dc7ad89cfe
+++ testresources-0.1/.bzr/revision-store/71/robertc@robertcollins.net-20050904004612-ed91f2dc7ad89cfe
@@ -0,0 +1,6 @@
+
+add the TestLoader
+
+
+
+
--- testresources-0.1.orig/.bzr/revision-store/74/robertc@robertcollins.net-20050904134722-5065a32e76d01b6e
+++ testresources-0.1/.bzr/revision-store/74/robertc@robertcollins.net-20050904134722-5065a32e76d01b6e
@@ -0,0 +1,6 @@
+
+heh, actually enable the resource sorting test
+
+
+
+
--- testresources-0.1.orig/.bzr/revision-store/48/robertc@robertcollins.net-20050904081216-97a972a5a0611b74
+++ testresources-0.1/.bzr/revision-store/48/robertc@robertcollins.net-20050904081216-97a972a5a0611b74
@@ -0,0 +1,6 @@
+
+deal with non ResourcedTestCases in OptimisingTestSuite.run
+
+
+
+
--- testresources-0.1.orig/.bzr/revision-store/52/robertc@robertcollins.net-20050904013507-2558f957d338d04b
+++ testresources-0.1/.bzr/revision-store/52/robertc@robertcollins.net-20050904013507-2558f957d338d04b
@@ -0,0 +1,6 @@
+
+provide a _cleanResource method for resource freeing.
+
+
+
+
--- testresources-0.1.orig/.bzr/revision-store/f2/robertc@robertcollins.net-20050904080857-d3be838de97553dd
+++ testresources-0.1/.bzr/revision-store/f2/robertc@robertcollins.net-20050904080857-d3be838de97553dd
@@ -0,0 +1,6 @@
+
+if the OptimisingTestSuites _tests is well sorted, optimise resource construction and removal
+
+
+
+
--- testresources-0.1.orig/.bzr/revision-store/6c/robertc@robertcollins.net-20050904005052-0fddf3e7c8d9fd3a
+++ testresources-0.1/.bzr/revision-store/6c/robertc@robertcollins.net-20050904005052-0fddf3e7c8d9fd3a
@@ -0,0 +1,6 @@
+
+create a TestResource
+
+
+
+
--- testresources-0.1.orig/.bzr/revision-store/a8/robertc@robertcollins.net-20050904010922-869a537b81ebfb20
+++ testresources-0.1/.bzr/revision-store/a8/robertc@robertcollins.net-20050904010922-869a537b81ebfb20
@@ -0,0 +1,6 @@
+
+support nested getResource calls to do the right thing.
+
+
+
+
--- testresources-0.1.orig/.bzr/revision-store/a8/robertc@robertcollins.net-20050904074811-ac5e82d554a018e3
+++ testresources-0.1/.bzr/revision-store/a8/robertc@robertcollins.net-20050904074811-ac5e82d554a018e3
@@ -0,0 +1,6 @@
+
+acquire test resources in OptimisingTestSuite
+
+
+
+
--- testresources-0.1.orig/.bzr/revision-store/ae/robertc@robertcollins.net-20050904071016-083acf76691fed70
+++ testresources-0.1/.bzr/revision-store/ae/robertc@robertcollins.net-20050904071016-083acf76691fed70
@@ -0,0 +1,6 @@
+
+initial implementation of ResourcedTestCase, found bug in TestResource implementation too.
+
+
+
+
--- testresources-0.1.orig/.bzr/revision-store/76/robertc@robertcollins.net-20050904003259-a335a92fb647113f
+++ testresources-0.1/.bzr/revision-store/76/robertc@robertcollins.net-20050904003259-a335a92fb647113f
@@ -0,0 +1,3 @@
+
+first post
+
--- testresources-0.1.orig/.bzr/revision-store/a3/robertc@robertcollins.net-20050904014403-6e8106d48aac2f09
+++ testresources-0.1/.bzr/revision-store/a3/robertc@robertcollins.net-20050904014403-6e8106d48aac2f09
@@ -0,0 +1,6 @@
+
+support dirtying the resource
+
+
+
+
--- testresources-0.1.orig/.bzr/revision-store/6e/robertc@robertcollins.net-20060215013125-a9198a84b94012bb
+++ testresources-0.1/.bzr/revision-store/6e/robertc@robertcollins.net-20060215013125-a9198a84b94012bb
@@ -0,0 +1,8 @@
+
+Add setup.py
+
+
+
+testresources
+
+
--- testresources-0.1.orig/.bzr/revision-store/d2/robertc@robertcollins.net-20050911111209-ee5da49011cf936a
+++ testresources-0.1/.bzr/revision-store/d2/robertc@robertcollins.net-20050911111209-ee5da49011cf936a
@@ -0,0 +1,6 @@
+
+give test resources setupUpCost and tearDownCost
+
+
+
+
--- testresources-0.1.orig/.bzr/revision-history
+++ testresources-0.1/.bzr/revision-history
@@ -0,0 +1,17 @@
+robertc@robertcollins.net-20050904003259-a335a92fb647113f
+robertc@robertcollins.net-20050904004612-ed91f2dc7ad89cfe
+robertc@robertcollins.net-20050904005052-0fddf3e7c8d9fd3a
+robertc@robertcollins.net-20050904010922-869a537b81ebfb20
+robertc@robertcollins.net-20050904011543-fc1dc855cee3deaa
+robertc@robertcollins.net-20050904013507-2558f957d338d04b
+robertc@robertcollins.net-20050904014403-6e8106d48aac2f09
+robertc@robertcollins.net-20050904071016-083acf76691fed70
+robertc@robertcollins.net-20050904072941-fa3cf56d8ea541a3
+robertc@robertcollins.net-20050904074811-ac5e82d554a018e3
+robertc@robertcollins.net-20050904080857-d3be838de97553dd
+robertc@robertcollins.net-20050904081216-97a972a5a0611b74
+robertc@robertcollins.net-20050904092827-b5ed46068a9231ef
+robertc@robertcollins.net-20050904134722-5065a32e76d01b6e
+robertc@robertcollins.net-20050905073000-2a3738a209cd8085
+robertc@robertcollins.net-20050911111209-ee5da49011cf936a
+robertc@robertcollins.net-20060215013125-a9198a84b94012bb
\ No newline at end of file
--- testresources-0.1.orig/.bzr/inventory
+++ testresources-0.1/.bzr/inventory
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--- testresources-0.1.orig/.bzr/weaves/07/COPYING-20050904000703-8c1890961f02a681.weave
+++ testresources-0.1/.bzr/weaves/07/COPYING-20050904000703-8c1890961f02a681.weave
@@ -0,0 +1,349 @@
+# bzr weave file v5
+i
+1 dfac199a7539a404407098a2541b9482279f690d
+n robertc@robertcollins.net-20050904003259-a335a92fb647113f
+
+w
+{ 0
+. GNU GENERAL PUBLIC LICENSE
+. Version 2, June 1991
+.
+. Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+. Everyone is permitted to copy and distribute verbatim copies
+. of this license document, but changing it is not allowed.
+.
+. Preamble
+.
+. The licenses for most software are designed to take away your
+. freedom to share and change it. By contrast, the GNU General Public
+. License is intended to guarantee your freedom to share and change free
+. software--to make sure the software is free for all its users. This
+. General Public License applies to most of the Free Software
+. Foundation's software and to any other program whose authors commit to
+. using it. (Some other Free Software Foundation software is covered by
+. the GNU Library General Public License instead.) You can apply it to
+. your programs, too.
+.
+. When we speak of free software, we are referring to freedom, not
+. price. Our General Public Licenses are designed to make sure that you
+. have the freedom to distribute copies of free software (and charge for
+. this service if you wish), that you receive source code or can get it
+. if you want it, that you can change the software or use pieces of it
+. in new free programs; and that you know you can do these things.
+.
+. To protect your rights, we need to make restrictions that forbid
+. anyone to deny you these rights or to ask you to surrender the rights.
+. These restrictions translate to certain responsibilities for you if you
+. distribute copies of the software, or if you modify it.
+.
+. For example, if you distribute copies of such a program, whether
+. gratis or for a fee, you must give the recipients all the rights that
+. you have. You must make sure that they, too, receive or can get the
+. source code. And you must show them these terms so they know their
+. rights.
+.
+. We protect your rights with two steps: (1) copyright the software, and
+. (2) offer you this license which gives you legal permission to copy,
+. distribute and/or modify the software.
+.
+. Also, for each author's protection and ours, we want to make certain
+. that everyone understands that there is no warranty for this free
+. software. If the software is modified by someone else and passed on, we
+. want its recipients to know that what they have is not the original, so
+. that any problems introduced by others will not reflect on the original
+. authors' reputations.
+.
+. Finally, any free program is threatened constantly by software
+. patents. We wish to avoid the danger that redistributors of a free
+. program will individually obtain patent licenses, in effect making the
+. program proprietary. To prevent this, we have made it clear that any
+. patent must be licensed for everyone's free use or not licensed at all.
+.
+. The precise terms and conditions for copying, distribution and
+. modification follow.
+.
+. GNU GENERAL PUBLIC LICENSE
+. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+.
+. 0. This License applies to any program or other work which contains
+. a notice placed by the copyright holder saying it may be distributed
+. under the terms of this General Public License. The "Program", below,
+. refers to any such program or work, and a "work based on the Program"
+. means either the Program or any derivative work under copyright law:
+. that is to say, a work containing the Program or a portion of it,
+. either verbatim or with modifications and/or translated into another
+. language. (Hereinafter, translation is included without limitation in
+. the term "modification".) Each licensee is addressed as "you".
+.
+. Activities other than copying, distribution and modification are not
+. covered by this License; they are outside its scope. The act of
+. running the Program is not restricted, and the output from the Program
+. is covered only if its contents constitute a work based on the
+. Program (independent of having been made by running the Program).
+. Whether that is true depends on what the Program does.
+.
+. 1. You may copy and distribute verbatim copies of the Program's
+. source code as you receive it, in any medium, provided that you
+. conspicuously and appropriately publish on each copy an appropriate
+. copyright notice and disclaimer of warranty; keep intact all the
+. notices that refer to this License and to the absence of any warranty;
+. and give any other recipients of the Program a copy of this License
+. along with the Program.
+.
+. You may charge a fee for the physical act of transferring a copy, and
+. you may at your option offer warranty protection in exchange for a fee.
+.
+. 2. You may modify your copy or copies of the Program or any portion
+. of it, thus forming a work based on the Program, and copy and
+. distribute such modifications or work under the terms of Section 1
+. above, provided that you also meet all of these conditions:
+.
+. a) You must cause the modified files to carry prominent notices
+. stating that you changed the files and the date of any change.
+.
+. b) You must cause any work that you distribute or publish, that in
+. whole or in part contains or is derived from the Program or any
+. part thereof, to be licensed as a whole at no charge to all third
+. parties under the terms of this License.
+.
+. c) If the modified program normally reads commands interactively
+. when run, you must cause it, when started running for such
+. interactive use in the most ordinary way, to print or display an
+. announcement including an appropriate copyright notice and a
+. notice that there is no warranty (or else, saying that you provide
+. a warranty) and that users may redistribute the program under
+. these conditions, and telling the user how to view a copy of this
+. License. (Exception: if the Program itself is interactive but
+. does not normally print such an announcement, your work based on
+. the Program is not required to print an announcement.)
+.
+. These requirements apply to the modified work as a whole. If
+. identifiable sections of that work are not derived from the Program,
+. and can be reasonably considered independent and separate works in
+. themselves, then this License, and its terms, do not apply to those
+. sections when you distribute them as separate works. But when you
+. distribute the same sections as part of a whole which is a work based
+. on the Program, the distribution of the whole must be on the terms of
+. this License, whose permissions for other licensees extend to the
+. entire whole, and thus to each and every part regardless of who wrote it.
+.
+. Thus, it is not the intent of this section to claim rights or contest
+. your rights to work written entirely by you; rather, the intent is to
+. exercise the right to control the distribution of derivative or
+. collective works based on the Program.
+.
+. In addition, mere aggregation of another work not based on the Program
+. with the Program (or with a work based on the Program) on a volume of
+. a storage or distribution medium does not bring the other work under
+. the scope of this License.
+.
+. 3. You may copy and distribute the Program (or a work based on it,
+. under Section 2) in object code or executable form under the terms of
+. Sections 1 and 2 above provided that you also do one of the following:
+.
+. a) Accompany it with the complete corresponding machine-readable
+. source code, which must be distributed under the terms of Sections
+. 1 and 2 above on a medium customarily used for software interchange; or,
+.
+. b) Accompany it with a written offer, valid for at least three
+. years, to give any third party, for a charge no more than your
+. cost of physically performing source distribution, a complete
+. machine-readable copy of the corresponding source code, to be
+. distributed under the terms of Sections 1 and 2 above on a medium
+. customarily used for software interchange; or,
+.
+. c) Accompany it with the information you received as to the offer
+. to distribute corresponding source code. (This alternative is
+. allowed only for noncommercial distribution and only if you
+. received the program in object code or executable form with such
+. an offer, in accord with Subsection b above.)
+.
+. The source code for a work means the preferred form of the work for
+. making modifications to it. For an executable work, complete source
+. code means all the source code for all modules it contains, plus any
+. associated interface definition files, plus the scripts used to
+. control compilation and installation of the executable. However, as a
+. special exception, the source code distributed need not include
+. anything that is normally distributed (in either source or binary
+. form) with the major components (compiler, kernel, and so on) of the
+. operating system on which the executable runs, unless that component
+. itself accompanies the executable.
+.
+. If distribution of executable or object code is made by offering
+. access to copy from a designated place, then offering equivalent
+. access to copy the source code from the same place counts as
+. distribution of the source code, even though third parties are not
+. compelled to copy the source along with the object code.
+.
+. 4. You may not copy, modify, sublicense, or distribute the Program
+. except as expressly provided under this License. Any attempt
+. otherwise to copy, modify, sublicense or distribute the Program is
+. void, and will automatically terminate your rights under this License.
+. However, parties who have received copies, or rights, from you under
+. this License will not have their licenses terminated so long as such
+. parties remain in full compliance.
+.
+. 5. You are not required to accept this License, since you have not
+. signed it. However, nothing else grants you permission to modify or
+. distribute the Program or its derivative works. These actions are
+. prohibited by law if you do not accept this License. Therefore, by
+. modifying or distributing the Program (or any work based on the
+. Program), you indicate your acceptance of this License to do so, and
+. all its terms and conditions for copying, distributing or modifying
+. the Program or works based on it.
+.
+. 6. Each time you redistribute the Program (or any work based on the
+. Program), the recipient automatically receives a license from the
+. original licensor to copy, distribute or modify the Program subject to
+. these terms and conditions. You may not impose any further
+. restrictions on the recipients' exercise of the rights granted herein.
+. You are not responsible for enforcing compliance by third parties to
+. this License.
+.
+. 7. If, as a consequence of a court judgment or allegation of patent
+. infringement or for any other reason (not limited to patent issues),
+. conditions are imposed on you (whether by court order, agreement or
+. otherwise) that contradict the conditions of this License, they do not
+. excuse you from the conditions of this License. If you cannot
+. distribute so as to satisfy simultaneously your obligations under this
+. License and any other pertinent obligations, then as a consequence you
+. may not distribute the Program at all. For example, if a patent
+. license would not permit royalty-free redistribution of the Program by
+. all those who receive copies directly or indirectly through you, then
+. the only way you could satisfy both it and this License would be to
+. refrain entirely from distribution of the Program.
+.
+. If any portion of this section is held invalid or unenforceable under
+. any particular circumstance, the balance of the section is intended to
+. apply and the section as a whole is intended to apply in other
+. circumstances.
+.
+. It is not the purpose of this section to induce you to infringe any
+. patents or other property right claims or to contest validity of any
+. such claims; this section has the sole purpose of protecting the
+. integrity of the free software distribution system, which is
+. implemented by public license practices. Many people have made
+. generous contributions to the wide range of software distributed
+. through that system in reliance on consistent application of that
+. system; it is up to the author/donor to decide if he or she is willing
+. to distribute software through any other system and a licensee cannot
+. impose that choice.
+.
+. This section is intended to make thoroughly clear what is believed to
+. be a consequence of the rest of this License.
+.
+. 8. If the distribution and/or use of the Program is restricted in
+. certain countries either by patents or by copyrighted interfaces, the
+. original copyright holder who places the Program under this License
+. may add an explicit geographical distribution limitation excluding
+. those countries, so that distribution is permitted only in or among
+. countries not thus excluded. In such case, this License incorporates
+. the limitation as if written in the body of this License.
+.
+. 9. The Free Software Foundation may publish revised and/or new versions
+. of the General Public License from time to time. Such new versions will
+. be similar in spirit to the present version, but may differ in detail to
+. address new problems or concerns.
+.
+. Each version is given a distinguishing version number. If the Program
+. specifies a version number of this License which applies to it and "any
+. later version", you have the option of following the terms and conditions
+. either of that version or of any later version published by the Free
+. Software Foundation. If the Program does not specify a version number of
+. this License, you may choose any version ever published by the Free Software
+. Foundation.
+.
+. 10. If you wish to incorporate parts of the Program into other free
+. programs whose distribution conditions are different, write to the author
+. to ask for permission. For software which is copyrighted by the Free
+. Software Foundation, write to the Free Software Foundation; we sometimes
+. make exceptions for this. Our decision will be guided by the two goals
+. of preserving the free status of all derivatives of our free software and
+. of promoting the sharing and reuse of software generally.
+.
+. NO WARRANTY
+.
+. 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+. FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+. OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+. PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+. OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+. TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+. PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+. REPAIR OR CORRECTION.
+.
+. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+. WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+. REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+. INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+. OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+. TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+. YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+. PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+. POSSIBILITY OF SUCH DAMAGES.
+.
+. END OF TERMS AND CONDITIONS
+.
+. How to Apply These Terms to Your New Programs
+.
+. If you develop a new program, and you want it to be of the greatest
+. possible use to the public, the best way to achieve this is to make it
+. free software which everyone can redistribute and change under these terms.
+.
+. To do so, attach the following notices to the program. It is safest
+. to attach them to the start of each source file to most effectively
+. convey the exclusion of warranty; and each file should have at least
+. the "copyright" line and a pointer to where the full notice is found.
+.
+.
+. Copyright (C)
+.
+. This program is free software; you can redistribute it and/or modify
+. it under the terms of the GNU General Public License as published by
+. the Free Software Foundation; either version 2 of the License, or
+. (at your option) any later version.
+.
+. This program is distributed in the hope that it will be useful,
+. but WITHOUT ANY WARRANTY; without even the implied warranty of
+. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+. GNU General Public License for more details.
+.
+. You should have received a copy of the GNU General Public License
+. along with this program; if not, write to the Free Software
+. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+.
+.
+. Also add information on how to contact you by electronic and paper mail.
+.
+. If the program is interactive, make it output a short notice like this
+. when it starts in an interactive mode:
+.
+. Gnomovision version 69, Copyright (C) year name of author
+. Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+. This is free software, and you are welcome to redistribute it
+. under certain conditions; type `show c' for details.
+.
+. The hypothetical commands `show w' and `show c' should show the appropriate
+. parts of the General Public License. Of course, the commands you use may
+. be called something other than `show w' and `show c'; they could even be
+. mouse-clicks or menu items--whatever suits your program.
+.
+. You should also get your employer (if you work as a programmer) or your
+. school, if any, to sign a "copyright disclaimer" for the program, if
+. necessary. Here is a sample; alter the names:
+.
+. Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+. `Gnomovision' (which makes passes at compilers) written by James Hacker.
+.
+. , 1 April 1989
+. Ty Coon, President of Vice
+.
+. This General Public License does not permit incorporating your program into
+. proprietary programs. If your program is a subroutine library, you may
+. consider it more useful to permit linking proprietary applications with the
+. library. If this is what you want to do, use the GNU Library General
+. Public License instead of this License.
+}
+W
--- testresources-0.1.orig/.bzr/weaves/a1/priodict.py-20050904092738-c036258d6cf07452.weave
+++ testresources-0.1/.bzr/weaves/a1/priodict.py-20050904092738-c036258d6cf07452.weave
@@ -0,0 +1,82 @@
+# bzr weave file v5
+i
+1 86e43bf1bafbd1d96275bb3b5955f4df40872092
+n robertc@robertcollins.net-20050904092827-b5ed46068a9231ef
+
+w
+{ 0
+. # python
+. # vim:ts=4:sw=4
+. # $Id: priodict.py,v 1.2 2003/12/09 23:40:33 kdart Exp $
+. # Priority dictionary using binary heaps
+. # David Eppstein, UC Irvine, 8 Mar 2002
+. # extracted from pyNMS.sourceforge.net - LGPL licence
+.
+. from __future__ import generators
+.
+. class priorityDictionary(dict):
+. def __init__(self):
+. '''Initialize priorityDictionary by creating binary heap
+. of pairs (value,key). Note that changing or removing a dict entry will
+. not remove the old pair from the heap until it is found by smallest() or
+. until the heap is rebuilt.'''
+. self.__heap = []
+. dict.__init__(self)
+.
+. def smallest(self):
+. '''Find smallest item after removing deleted items from heap.'''
+. if len(self) == 0:
+. raise IndexError, "smallest of empty priorityDictionary"
+. heap = self.__heap
+. while heap[0][1] not in self or self[heap[0][1]] != heap[0][0]:
+. lastItem = heap.pop()
+. insertionPoint = 0
+. while 1:
+. smallChild = 2*insertionPoint+1
+. if smallChild+1 < len(heap) and \
+. heap[smallChild] > heap[smallChild+1]:
+. smallChild += 1
+. if smallChild >= len(heap) or lastItem <= heap[smallChild]:
+. heap[insertionPoint] = lastItem
+. break
+. heap[insertionPoint] = heap[smallChild]
+. insertionPoint = smallChild
+. return heap[0][1]
+.
+. def __iter__(self):
+. '''Create destructive sorted iterator of priorityDictionary.'''
+. def iterfn():
+. while len(self) > 0:
+. x = self.smallest()
+. yield x
+. del self[x]
+. return iterfn()
+.
+. def __setitem__(self,key,val):
+. '''Change value stored in dictionary and add corresponding
+. pair to heap. Rebuilds the heap if the number of deleted items grows
+. too large, to avoid memory leakage.'''
+. dict.__setitem__(self,key,val)
+. heap = self.__heap
+. if len(heap) > 2 * len(self):
+. self.__heap = [(v,k) for k,v in self.iteritems()]
+. self.__heap.sort() # builtin sort likely faster than O(n) heapify
+. else:
+. newPair = (val,key)
+. insertionPoint = len(heap)
+. heap.append(None)
+. while insertionPoint > 0 and \
+. newPair < heap[(insertionPoint-1)//2]:
+. heap[insertionPoint] = heap[(insertionPoint-1)//2]
+. insertionPoint = (insertionPoint-1)//2
+. heap[insertionPoint] = newPair
+.
+. def setdefault(self,key,val):
+. '''Reimplement setdefault to call our customized __setitem__.'''
+. if key not in self:
+. self[key] = val
+. return self[key]
+.
+.
+}
+W
--- testresources-0.1.orig/.bzr/weaves/50/lib-20050904003059-91f8fa058ee2eeeb.weave
+++ testresources-0.1/.bzr/weaves/50/lib-20050904003059-91f8fa058ee2eeeb.weave
@@ -0,0 +1,7 @@
+# bzr weave file v5
+i
+1 da39a3ee5e6b4b0d3255bfef95601890afd80709
+n robertc@robertcollins.net-20050904003259-a335a92fb647113f
+
+w
+W
--- testresources-0.1.orig/.bzr/weaves/7f/test_test_loader.py-20050904004511-d8e6aa9c7e3581e2.weave
+++ testresources-0.1/.bzr/weaves/7f/test_test_loader.py-20050904004511-d8e6aa9c7e3581e2.weave
@@ -0,0 +1,44 @@
+# bzr weave file v5
+i
+1 11ca4960996e9ff528187cdd26dc8b3eee79b150
+n robertc@robertcollins.net-20050904004612-ed91f2dc7ad89cfe
+
+w
+{ 0
+. #
+. # testresources: extensions to python unittest to allow declaritive use
+. # of resources by test cases.
+. # Copyright (C) 2005 Robert Collins
+. #
+. # This program is free software; you can redistribute it and/or modify
+. # it under the terms of the GNU General Public License as published by
+. # the Free Software Foundation; either version 2 of the License, or
+. # (at your option) any later version.
+. #
+. # This program is distributed in the hope that it will be useful,
+. # but WITHOUT ANY WARRANTY; without even the implied warranty of
+. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+. # GNU General Public License for more details.
+. #
+. # You should have received a copy of the GNU General Public License
+. # along with this program; if not, write to the Free Software
+. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+. #
+.
+. import unittest
+. import testresources.tests
+.
+. def test_suite():
+. loader = testresources.tests.TestUtil.TestLoader()
+. result = loader.loadTestsFromName(__name__)
+. return result
+.
+.
+. class TestTestLoader(unittest.TestCase):
+.
+. def testSuiteType(self):
+. loader = testresources.TestLoader()
+. suite = loader.loadTestsFromName(__name__)
+. self.failUnless(isinstance(suite, testresources.OptimisingTestSuite))
+}
+W
--- testresources-0.1.orig/.bzr/weaves/d2/test_resourced_test_case.py-20050904070948-56c4123d3e3fcfe0.weave
+++ testresources-0.1/.bzr/weaves/d2/test_resourced_test_case.py-20050904070948-56c4123d3e3fcfe0.weave
@@ -0,0 +1,97 @@
+# bzr weave file v5
+i
+1 dad996192dc2756d667bbc1df23ca15a32a40c34
+n robertc@robertcollins.net-20050904071016-083acf76691fed70
+
+w
+{ 0
+. #
+. # testresources: extensions to python unittest to allow declaritive use
+. # of resources by test cases.
+. # Copyright (C) 2005 Robert Collins
+. #
+. # This program is free software; you can redistribute it and/or modify
+. # it under the terms of the GNU General Public License as published by
+. # the Free Software Foundation; either version 2 of the License, or
+. # (at your option) any later version.
+. #
+. # This program is distributed in the hope that it will be useful,
+. # but WITHOUT ANY WARRANTY; without even the implied warranty of
+. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+. # GNU General Public License for more details.
+. #
+. # You should have received a copy of the GNU General Public License
+. # along with this program; if not, write to the Free Software
+. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+. #
+.
+. import testresources
+. import testresources.tests
+. import unittest
+.
+. def test_suite():
+. loader = testresources.tests.TestUtil.TestLoader()
+. result = loader.loadTestsFromName(__name__)
+. return result
+.
+.
+. class TestResourcedTestCase(unittest.TestCase):
+.
+. def testImports(self):
+. from testresources import ResourcedTestCase
+.
+. def testDefaults(self):
+. case = testresources.ResourcedTestCase("run")
+. case.setUpResources(case)
+. case.tearDownResources(case)
+. self.assertEqual(case._resources, [])
+.
+. def testSingleResource(self):
+. case = testresources.ResourcedTestCase("run")
+. case._resources = [("_default", testresources.SampleTestResource)]
+. case.setUpResources(case)
+. self.assertEqual(case._default,
+. "You need to implement your own "
+. "getResource.")
+. self.assertEqual(testresources.SampleTestResource._uses, 1)
+. case.tearDownResources(case)
+. self.failIf(hasattr(case, "_default"))
+. self.assertEqual(testresources.SampleTestResource._uses, 0)
+.
+. def testSingleWithSetup(self):
+. case = testresources.ResourcedTestCase("run")
+. case._resources = [("_default", testresources.SampleTestResource)]
+. case.setUp()
+. self.assertEqual(case._default,
+. "You need to implement your own "
+. "getResource.")
+. self.assertEqual(testresources.SampleTestResource._uses, 1)
+. case.tearDown()
+. self.failIf(hasattr(case, "_default"))
+. self.assertEqual(testresources.SampleTestResource._uses, 0)
+.
+. def testMultipleResources(self):
+.
+. class MockResource(testresources.TestResource):
+.
+. @classmethod
+. def _makeResource(self):
+. return "Boo!"
+.
+. case = testresources.ResourcedTestCase("run")
+. case._resources = [("_default", testresources.SampleTestResource),
+. ("_mock", MockResource)]
+. case.setUpResources(case)
+. self.assertEqual(case._default,
+. "You need to implement your own "
+. "getResource.")
+. self.assertEqual(case._mock, "Boo!")
+. self.assertEqual(testresources.SampleTestResource._uses, 1)
+. self.assertEqual(MockResource._uses, 1)
+. case.tearDownResources(case)
+. self.failIf(hasattr(case, "_default"))
+. self.assertEqual(testresources.SampleTestResource._uses, 0)
+. self.failIf(hasattr(case, "_mock"))
+. self.assertEqual(MockResource._uses, 0)
+}
+W
--- testresources-0.1.orig/.bzr/weaves/73/dijkstra.py-20050904092738-b9dee94a8f7f187b.weave
+++ testresources-0.1/.bzr/weaves/73/dijkstra.py-20050904092738-b9dee94a8f7f187b.weave
@@ -0,0 +1,98 @@
+# bzr weave file v5
+i
+1 82608e711ae39ce280c360e644c3f4b9b4742f12
+n robertc@robertcollins.net-20050904092827-b5ed46068a9231ef
+
+w
+{ 0
+.
+.
+. # Dijkstra's algorithm for shortest paths
+. # David Eppstein, UC Irvine, 4 April 2002
+.
+. # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/117228
+. from priodict import priorityDictionary
+.
+. def Dijkstra(G,start,end=None):
+. """
+. Find shortest paths from the start vertex to all
+. vertices nearer than or equal to the end.
+.
+. The input graph G is assumed to have the following
+. representation: A vertex can be any object that can
+. be used as an index into a dictionary. G is a
+. dictionary, indexed by vertices. For any vertex v,
+. G[v] is itself a dictionary, indexed by the neighbors
+. of v. For any edge v->w, G[v][w] is the length of
+. the edge. This is related to the representation in
+.
+. where Guido van Rossum suggests representing graphs
+. as dictionaries mapping vertices to lists of neighbors,
+. however dictionaries of edges have many advantages
+. over lists: they can store extra information (here,
+. the lengths), they support fast existence tests,
+. and they allow easy modification of the graph by edge
+. insertion and removal. Such modifications are not
+. needed here but are important in other graph algorithms.
+. Since dictionaries obey iterator protocol, a graph
+. represented as described here could be handed without
+. modification to an algorithm using Guido's representation.
+.
+. Of course, G and G[v] need not be Python dict objects;
+. they can be any other object that obeys dict protocol,
+. for instance a wrapper in which vertices are URLs
+. and a call to G[v] loads the web page and finds its links.
+.
+. The output is a pair (D,P) where D[v] is the distance
+. from start to v and P[v] is the predecessor of v along
+. the shortest path from s to v.
+.
+. Dijkstra's algorithm is only guaranteed to work correctly
+. when all edge lengths are positive. This code does not
+. verify this property for all edges (only the edges seen
+. before the end vertex is reached), but will correctly
+. compute shortest paths even for some graphs with negative
+. edges, and will raise an exception if it discovers that
+. a negative edge has caused it to make a mistake.
+. """
+.
+. D = {} # dictionary of final distances
+. P = {} # dictionary of predecessors
+. Q = priorityDictionary() # est.dist. of non-final vert.
+. Q[start] = 0
+.
+. for v in Q:
+. D[v] = Q[v]
+. if v == end: break
+.
+. for w in G[v]:
+. vwLength = D[v] + G[v][w]
+. if w in D:
+. if vwLength < D[w]:
+. raise ValueError, \
+. "Dijkstra: found better path to already-final vertex"
+. elif w not in Q or vwLength < Q[w]:
+. Q[w] = vwLength
+. P[w] = v
+.
+. return (D,P)
+.
+. def shortestPath(G,start,end):
+. """
+. Find a single shortest path from the given start vertex
+. to the given end vertex.
+. The input has the same conventions as Dijkstra().
+. The output is a list of the vertices in order along
+. the shortest path.
+. """
+.
+. D,P = Dijkstra(G,start,end)
+. Path = []
+. while 1:
+. Path.append(end)
+. if end == start: break
+. end = P[end]
+. Path.reverse()
+. return Path
+}
+W
--- testresources-0.1.orig/.bzr/weaves/db/testresources-20050904003059-6cc165d3a12a0219.weave
+++ testresources-0.1/.bzr/weaves/db/testresources-20050904003059-6cc165d3a12a0219.weave
@@ -0,0 +1,7 @@
+# bzr weave file v5
+i
+1 da39a3ee5e6b4b0d3255bfef95601890afd80709
+n robertc@robertcollins.net-20050904003259-a335a92fb647113f
+
+w
+W
--- testresources-0.1.orig/.bzr/weaves/91/__init__.py-20050904003059-376a3f1bd80802f1.weave
+++ testresources-0.1/.bzr/weaves/91/__init__.py-20050904003059-376a3f1bd80802f1.weave
@@ -0,0 +1,384 @@
+# bzr weave file v5
+i
+1 6b69c0a64c2710d1c3372ce5e6e2685ede86d01f
+n robertc@robertcollins.net-20050904003259-a335a92fb647113f
+
+i 0
+1 dd159c84ccc151dd6acd9eae7f0d015384f33361
+n robertc@robertcollins.net-20050904004612-ed91f2dc7ad89cfe
+
+i 1
+1 a9700ef0f1fc183f3e9c7647985aedc771317a92
+n robertc@robertcollins.net-20050904005052-0fddf3e7c8d9fd3a
+
+i 2
+1 79bde5b23b38e85f0534dcfd79297253970e673a
+n robertc@robertcollins.net-20050904010922-869a537b81ebfb20
+
+i 3
+1 5dc7ad37f34080253493fb411eeba7c0e8e90f31
+n robertc@robertcollins.net-20050904011543-fc1dc855cee3deaa
+
+i 4
+1 7e7e27d9fc73dde43264283115e8796c37f3a7e1
+n robertc@robertcollins.net-20050904013507-2558f957d338d04b
+
+i 5
+1 26116dc297d1ddc63422d669ec88e3ea5fad03ac
+n robertc@robertcollins.net-20050904014403-6e8106d48aac2f09
+
+i 6
+1 1f104d64e4c31bf43c33d19f3209caa12df2d4e5
+n robertc@robertcollins.net-20050904071016-083acf76691fed70
+
+i 7
+1 1d185945ac3d3c6ef4091bde727b32d74a980160
+n robertc@robertcollins.net-20050904072941-fa3cf56d8ea541a3
+
+i 8
+1 8e6a8793cb5ceca2a0e5e7b5208cacf0a60ccb55
+n robertc@robertcollins.net-20050904074811-ac5e82d554a018e3
+
+i 9
+1 fbbac360cb0969b37368887bfa4fec5434f9bb51
+n robertc@robertcollins.net-20050904080857-d3be838de97553dd
+
+i 10
+1 39a5cb7ea666c684820bd37cff03a916d02ee637
+n robertc@robertcollins.net-20050904081216-97a972a5a0611b74
+
+i 11
+1 af005c6decbcc06811d00d9af2efacc286011e58
+n robertc@robertcollins.net-20050904092827-b5ed46068a9231ef
+
+i 12
+1 90a11ae5b566ba5851a85cec75a7444a2f625ff7
+n robertc@robertcollins.net-20050904134722-5065a32e76d01b6e
+
+i 13
+1 bc8e3c119c6c28b4b3ea58a47e8cf9403520a541
+n robertc@robertcollins.net-20050911111209-ee5da49011cf936a
+
+w
+{ 0
+. #
+. # testresources: extensions to python unittest to allow declaritive use
+. # of resources by test cases.
+. # Copyright (C) 2005 Robert Collins
+. #
+. # This program is free software; you can redistribute it and/or modify
+. # it under the terms of the GNU General Public License as published by
+. # the Free Software Foundation; either version 2 of the License, or
+. # (at your option) any later version.
+. #
+. # This program is distributed in the hope that it will be useful,
+. # but WITHOUT ANY WARRANTY; without even the implied warranty of
+. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+. # GNU General Public License for more details.
+. #
+. # You should have received a copy of the GNU General Public License
+. # along with this program; if not, write to the Free Software
+. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+. #
+.
+{ 1
+{ 12
+. from copy import copy
+}
+. import unittest
+{ 8
+. import testresources.tests.TestUtil as TestUtil
+}
+.
+}
+. def test_suite():
+. import testresources.tests
+. return testresources.tests.test_suite()
+.
+}
+{ 1
+.
+{ 8
+. class TestAdder(TestUtil.TestVisitor):
+.
+. def __init__(self, suite):
+. self._suite = suite
+.
+. def visitCase(self, case):
+. self._suite.addTest(case)
+.
+.
+}
+. class OptimisingTestSuite(unittest.TestSuite):
+. """A resource creation optimising TestSuite."""
+{ 8
+.
+. def adsorbSuite(self, suite):
+. """adsorb all the tests in suite recursively.
+.
+. This allows full optimisation of the tests, but will remove
+. any containing TestSuites, which might be extending unittest
+. around those tests.
+. """
+. testAdder = TestAdder(self)
+. TestUtil.visitTests(suite, testAdder)
+}
+{ 9
+.
+. def run(self, result):
+{ 10
+{ 12
+. self.sortTests()
+}
+. current_resources = {}
+}
+. for test in self._tests:
+. if result.shouldStop:
+. break
+[ 10
+. current_resources = {}
+] 10
+{ 10
+[ 11
+. new_resources = {}
+}
+. for attribute, resource in test._resources:
+. if not resource in current_resources.keys():
+. current_resources[resource] = resource.getResource()
+{ 10
+. new_resources[resource] = current_resources[resource]
+. for resource in current_resources.keys():
+. if not resource in new_resources:
+. resource.finishedWith(current_resources[resource])
+. current_resources = new_resources
+}
+] 11
+{ 11
+. if hasattr(test, "_resources"):
+. new_resources = {}
+. for attribute, resource in test._resources:
+. if not resource in current_resources.keys():
+. current_resources[resource] = resource.getResource()
+. new_resources[resource] = current_resources[resource]
+. for resource in current_resources.keys():
+. if not resource in new_resources:
+. resource.finishedWith(current_resources[resource])
+. current_resources = new_resources
+}
+. test(result)
+[ 10
+. for resource, value in current_resources.items():
+. resource.finishedWith(value)
+] 10
+{ 10
+. for resource, value in current_resources.items():
+. resource.finishedWith(value)
+}
+. return result
+}
+{ 12
+.
+. def sortTests(self):
+. """Attempt to topographically sort the contained tests.
+.
+. Feel free to override to improve the sort behaviour.
+. """
+. # quick hack on the plane. Need to lookup graph textbook.
+. sorted = []
+. graph, legacy = self._getGraph()
+. # now we have a graph, we can do lovely things like
+. # travelling salesman on it. Blech. So we just take the
+. # dijkstra for this. I think this will usually generate reasonable
+. # behaviour - its just that the needed starting resources
+. # are quite arbitrary and can thus make things less than
+. # optimal.
+. from testresources.dijkstra import Dijkstra
+. if len(graph.keys()) > 0:
+. distances, predecessors = Dijkstra(graph, graph.keys()[0])
+. # and sort by distance
+. nodes = distances.items()
+. nodes.sort(key=lambda x:x[1])
+. for test, distance in nodes:
+. sorted.append(test)
+. self._tests = sorted + legacy
+.
+. def _getGraph(self):
+. """Build a graph of the resource using nodes."""
+. # build a mesh graph where a node is a test, and
+. # and the number of resources to change to another test
+. # is the cost to travel straight to that node.
+. legacy = []
+. graph = {}
+. pending = []
+. temp_pending = copy(self._tests)
+. if len(temp_pending) == 0:
+. return {}, []
+. for test in temp_pending:
+. if not hasattr(test, "_resources"):
+. legacy.append(test)
+. continue
+. pending.append(test)
+. graph[test] = {}
+. while len(pending):
+. test = pending.pop()
+. test_resources = set(test._resources)
+. for othertest in pending:
+. othertest_resources = set(othertest._resources)
+. cost = len(test_resources.symmetric_difference(
+. othertest_resources))
+. graph[test][othertest] = cost
+. graph[othertest][test] = cost
+. return graph, legacy
+}
+[ 13
+.
+] 13
+{ 13
+.
+.
+}
+. class TestLoader(unittest.TestLoader):
+. """Custom TestLoader to set the right TestSuite class."""
+. suiteClass = OptimisingTestSuite
+}
+{ 2
+{ 12
+.
+}
+.
+. class TestResource(object):
+. """A TestResource for persistent resources needed across tests."""
+.
+}
+{ 3
+[ 7
+. _currentResource = None
+{ 6
+. _dirty = False
+}
+. _uses = 0
+.
+{ 5
+] 7
+{ 14
+. setUpCost = 1
+. """The relative cost to construct a resource of this type."""
+. tearDownCost = 1
+. """The relative cost to tear down a resource of this type."""
+.
+}
+. def _cleanResource(cls, resource):
+. """Override this to class method to hook into resource removal."""
+. _cleanResource = classmethod(_cleanResource)
+.
+}
+{ 6
+. def dirtied(cls, resource):
+. cls._dirty = True
+. dirtied = classmethod(dirtied)
+.
+}
+. def finishedWith(cls, resource):
+. cls._uses -= 1
+. if cls._uses == 0:
+{ 5
+. cls._cleanResource(resource)
+}
+. cls._currentResource = None
+{ 6
+. elif cls._dirty:
+. cls._cleanResource(resource)
+. cls.setResource()
+}
+. finishedWith = classmethod(finishedWith)
+.
+. def getResource(cls):
+{ 7
+. if not hasattr(cls, "_uses"):
+. cls._currentResource = None
+. cls._dirty = False
+. cls._uses = 0
+}
+. if cls._uses == 0:
+[ 4
+. cls._currentResource = "You need to implement your own getResource."
+] 4
+{ 4
+[ 6
+. cls._currentResource = cls._makeResource()
+}
+] 6
+{ 6
+. cls.setResource()
+}
+. cls._uses += 1
+. return cls._currentResource
+. getResource = classmethod(getResource)
+}
+{ 4
+.
+{ 7
+. @classmethod
+}
+. def _makeResource(cls):
+[ 7
+. return "You need to implement your own getResource."
+. _makeResource = classmethod(_makeResource)
+}
+{ 6
+] 7
+{ 7
+. """Override this to construct resources."""
+. raise NotImplementedError("Override _makeResource to construct "
+. "resources.")
+}
+.
+. def setResource(cls):
+. """Set the current resource to a new value."""
+. cls._currentResource = cls._makeResource()
+. cls._dirty = False
+. setResource = classmethod(setResource)
+}
+{ 7
+.
+{ 14
+.
+}
+. class SampleTestResource(TestResource):
+{ 14
+.
+. setUpCost = 2
+. tearDownCost = 2
+}
+.
+. @classmethod
+. def _makeResource(cls):
+. return "You need to implement your own getResource."
+.
+.
+. class ResourcedTestCase(unittest.TestCase):
+. """A TestCase parent or utility that enables cross-test resource usage."""
+.
+. _resources = []
+.
+. def setUp(self):
+. unittest.TestCase.setUp(self)
+. self.setUpResources(self)
+.
+. @staticmethod
+. def setUpResources(case):
+. for resource in case._resources:
+. setattr(case, resource[0], resource[1].getResource())
+.
+. def tearDown(self):
+. self.tearDownResources(self)
+. unittest.TestCase.tearDown(self)
+.
+. @staticmethod
+. def tearDownResources(case):
+. for resource in case._resources:
+. resource[1].finishedWith(getattr(case, resource[0]))
+. delattr(case, resource[0])
+.
+}
+W
--- testresources-0.1.orig/.bzr/weaves/3f/test_optimising_test_suite.py-20050904072922-543ac6f0142f8242.weave
+++ testresources-0.1/.bzr/weaves/3f/test_optimising_test_suite.py-20050904072922-543ac6f0142f8242.weave
@@ -0,0 +1,221 @@
+# bzr weave file v5
+i
+1 3f7bcd317eebbe5dbc7d0dd59bee6ddf44bbb358
+n robertc@robertcollins.net-20050904072941-fa3cf56d8ea541a3
+
+i 0
+1 49ed819a466960722e8f364f430111fe9ed8a8c2
+n robertc@robertcollins.net-20050904074811-ac5e82d554a018e3
+
+i 1
+1 cd9f45155c1c69484057602a7703cb1ed52e2f1a
+n robertc@robertcollins.net-20050904080857-d3be838de97553dd
+
+i 2
+1 e80f7779184f5fdebbd8a139ce620ea730193575
+n robertc@robertcollins.net-20050904081216-97a972a5a0611b74
+
+i 3
+1 c2c63966bd059a5b3c4483f30ed3d758b82366ca
+n robertc@robertcollins.net-20050904092827-b5ed46068a9231ef
+
+i 4
+1 7a22d8afd4bcf55b2942b716851b93d0b8813983
+n robertc@robertcollins.net-20050904134722-5065a32e76d01b6e
+
+w
+{ 0
+. #
+. # testresources: extensions to python unittest to allow declaritive use
+. # of resources by test cases.
+. # Copyright (C) 2005 Robert Collins
+. #
+. # This program is free software; you can redistribute it and/or modify
+. # it under the terms of the GNU General Public License as published by
+. # the Free Software Foundation; either version 2 of the License, or
+. # (at your option) any later version.
+. #
+. # This program is distributed in the hope that it will be useful,
+. # but WITHOUT ANY WARRANTY; without even the implied warranty of
+. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+. # GNU General Public License for more details.
+. #
+. # You should have received a copy of the GNU General Public License
+. # along with this program; if not, write to the Free Software
+. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+. #
+.
+. import testresources
+. import testresources.tests
+. import unittest
+.
+. def test_suite():
+. loader = testresources.tests.TestUtil.TestLoader()
+. result = loader.loadTestsFromName(__name__)
+. return result
+.
+.
+. class TestOptimisingTestSuite(unittest.TestCase):
+.
+. def testImports(self):
+. from testresources import OptimisingTestSuite
+.
+. def testAdsorbSuiteWithCase(self):
+. suite = testresources.OptimisingTestSuite()
+. case = unittest.TestCase("run")
+. suite.adsorbSuite(case)
+. self.assertEqual(len(suite._tests), 1)
+. self.assertEqual(suite._tests[0], case)
+}
+{ 1
+.
+. def testSingleCaseResourceAcquisition(self):
+. class ResourceChecker(testresources.ResourcedTestCase):
+. _resources = [("_default", testresources.SampleTestResource)]
+. def getResourceCount(self):
+. self.assertEqual(testresources.SampleTestResource._uses, 2)
+.
+. suite = testresources.OptimisingTestSuite()
+. case = ResourceChecker("getResourceCount")
+. suite.addTest(case)
+. result = unittest.TestResult()
+. suite.run(result)
+. self.assertEqual(result.testsRun, 1)
+. self.assertEqual(result.errors, [])
+. self.assertEqual(result.failures, [])
+. self.assertEqual(testresources.SampleTestResource._uses, 0)
+.
+{ 2
+. def testResourceReuse(self):
+}
+.
+}
+{ 2
+. class MakeCounter(testresources.TestResource):
+.
+. cleans = 0
+. makes = 0
+. @classmethod
+. def _cleanResource(cls, resource):
+. cls.cleans += 1
+. @classmethod
+. def _makeResource(cls):
+. cls.makes += 1
+. return "boo"
+.
+. class ResourceChecker(testresources.ResourcedTestCase):
+. _resources = [("_default", MakeCounter)]
+. def getResourceCount(self):
+. self.assertEqual(MakeCounter._uses, 2)
+.
+. suite = testresources.OptimisingTestSuite()
+. case = ResourceChecker("getResourceCount")
+{ 4
+. case2 = ResourceChecker("getResourceCount")
+}
+. suite.addTest(case)
+[ 4
+. suite.addTest(case)
+] 4
+{ 4
+. suite.addTest(case2)
+}
+. result = unittest.TestResult()
+. suite.run(result)
+. self.assertEqual(result.testsRun, 2)
+. self.assertEqual(result.errors, [])
+. self.assertEqual(result.failures, [])
+. self.assertEqual(MakeCounter._uses, 0)
+. self.assertEqual(MakeCounter.makes, 1)
+. self.assertEqual(MakeCounter.cleans, 1)
+}
+{ 3
+.
+. def testOptimisedRunNonResourcedTestCase(self):
+. class MockTest(unittest.TestCase):
+. def test_nothing(self):
+. pass
+. suite = testresources.OptimisingTestSuite()
+. case = MockTest("test_nothing")
+. suite.addTest(case)
+. result = unittest.TestResult()
+. suite.run(result)
+. self.assertEqual(result.testsRun, 1)
+. self.assertEqual(result.errors, [])
+. self.assertEqual(result.failures, [])
+}
+{ 4
+.
+. def testSortTestsCalled(self):
+. class MockOptimisingTestSuite(testresources.OptimisingTestSuite):
+. def sortTests(self):
+. self.sorted = True
+.
+. suite = MockOptimisingTestSuite()
+. suite.sorted = False
+. suite.run(None)
+. self.assertEqual(suite.sorted, True)
+.
+. class TestGraphStuff(unittest.TestCase):
+.
+. def setUp(self):
+.
+. class MockTest(unittest.TestCase):
+. def test_one(self):
+. pass
+. def test_two(self):
+. pass
+. def test_three(self):
+. pass
+. def test_four(self):
+. pass
+.
+. class ResourceOne(testresources.TestResource):
+. pass
+.
+. class ResourceTwo(testresources.TestResource):
+. pass
+.
+. class ResourceThree(testresources.TestResource):
+. pass
+.
+. self.suite = testresources.OptimisingTestSuite()
+. self.case1 = MockTest("test_one")
+. self.case1._resources = [("_one", ResourceOne),
+. ("_two", ResourceTwo)]
+. self.case2 = MockTest("test_two")
+. self.case2._resources = [("_two", ResourceTwo),
+. ("_three", ResourceThree)]
+. self.case3 = MockTest("test_three")
+. self.case3._resources = [("_three", ResourceThree)]
+. self.case4 = MockTest("test_four")
+. self.suite.addTests([self.case3, self.case1, self.case4, self.case2])
+. # acceptable sorted orders are:
+. # 1, 2, 3, 4
+. # 3, 2, 1, 4
+.
+. def testBasicSortTests(self):
+. self.suite.sortTests()
+[ 5
+. print self.suite._tests
+. return
+] 5
+. self.failUnless(self.suite._tests == [self.case1, self.case2,
+. self.case3, self.case4] or
+. self.suite._tests == [self.case3, self.case2,
+. self.case1, self.case4])
+.
+. def testGetGraph(self):
+. graph, legacy = self.suite._getGraph()
+. case1vertex = {self.case2:2, self.case3:3}
+. case2vertex = {self.case1:2, self.case3:1}
+. case3vertex = {self.case1:3, self.case2:1}
+. self.assertEqual(legacy, [self.case4])
+. self.assertEqual(graph[self.case1], case1vertex)
+. self.assertEqual(graph[self.case2], case2vertex)
+. self.assertEqual(graph[self.case3], case3vertex)
+. self.assertEqual(graph, {self.case1:case1vertex,
+. self.case2:case2vertex,
+. self.case3:case3vertex})
+}
+W
--- testresources-0.1.orig/.bzr/weaves/11/tests-20050904003059-4e0f27c1d76dade3.weave
+++ testresources-0.1/.bzr/weaves/11/tests-20050904003059-4e0f27c1d76dade3.weave
@@ -0,0 +1,7 @@
+# bzr weave file v5
+i
+1 da39a3ee5e6b4b0d3255bfef95601890afd80709
+n robertc@robertcollins.net-20050904003259-a335a92fb647113f
+
+w
+W
--- testresources-0.1.orig/.bzr/weaves/a8/test_all.py-20050904000703-1cdea3f4ffabb947.weave
+++ testresources-0.1/.bzr/weaves/a8/test_all.py-20050904000703-1cdea3f4ffabb947.weave
@@ -0,0 +1,140 @@
+# bzr weave file v5
+i
+1 b6c3d6f6c2915dfdce50b09152c2ba9cc73edf67
+n robertc@robertcollins.net-20050904003259-a335a92fb647113f
+
+i 0
+1 b6c3d6f6c2915dfdce50b09152c2ba9cc73edf67
+n robertc@robertcollins.net-20060215013125-a9198a84b94012bb
+
+w
+{ 0
+. #!/usr/bin/env python
+. # -*- Mode: python -*-
+. #
+. # Copyright (C) 2004 Canonical.com
+. # Author: Robert Collins
+. #
+. # This program is free software; you can redistribute it and/or modify
+. # it under the terms of the GNU General Public License as published by
+. # the Free Software Foundation; either version 2 of the License, or
+. # (at your option) any later version.
+. #
+. # This program is distributed in the hope that it will be useful,
+. # but WITHOUT ANY WARRANTY; without even the implied warranty of
+. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+. # GNU General Public License for more details.
+. #
+. # You should have received a copy of the GNU General Public License
+. # along with this program; if not, write to the Free Software
+. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+. #
+.
+. import unittest
+. import sys
+. import os
+. import shutil
+. import logging
+.
+. class ParameterisableTextTestRunner(unittest.TextTestRunner):
+. """I am a TextTestRunner whose result class is
+. parameterisable without further subclassing"""
+. def __init__(self, **args):
+. unittest.TextTestRunner.__init__(self, **args)
+. self._resultFactory=None
+. def resultFactory(self, *args):
+. """set or retrieve the result factory"""
+. if args:
+. self._resultFactory=args[0]
+. return self
+. if self._resultFactory is None:
+. self._resultFactory=unittest._TextTestResult
+. return self._resultFactory
+.
+. def _makeResult(self):
+. return self.resultFactory()(self.stream, self.descriptions, self.verbosity)
+.
+.
+. class EarlyStoppingTextTestResult(unittest._TextTestResult):
+. """I am a TextTestResult that can optionally stop at the first failure
+. or error"""
+.
+. def addError(self, test, err):
+. unittest._TextTestResult.addError(self, test, err)
+. if self.stopOnError():
+. self.stop()
+.
+. def addFailure(self, test, err):
+. unittest._TextTestResult.addError(self, test, err)
+. if self.stopOnFailure():
+. self.stop()
+.
+. def stopOnError(self, *args):
+. """should this result indicate an abort when an error occurs?
+. TODO parameterise this"""
+. return True
+.
+. def stopOnFailure(self, *args):
+. """should this result indicate an abort when a failure error occurs?
+. TODO parameterise this"""
+. return True
+.
+.
+. def earlyStopFactory(*args, **kwargs):
+. """return a an early stopping text test result"""
+. result=EarlyStoppingTextTestResult(*args, **kwargs)
+. return result
+.
+. from testresources.tests.TestUtil import TestVisitor, TestSuite
+.
+. def test_suite():
+. result = TestSuite()
+. import testresources
+. result.addTest(testresources.test_suite())
+. return result
+.
+.
+. class filteringVisitor(TestVisitor):
+. """I accruse all the testCases I visit that pass a regexp filter on id
+. into my suite
+. """
+.
+. def __init__(self, filter):
+. import re
+. TestVisitor.__init__(self)
+. self._suite=None
+. self.filter=re.compile(filter)
+.
+. def suite(self):
+. """answer the suite we are building"""
+. if self._suite is None:
+. self._suite=TestSuite()
+. return self._suite
+.
+. def visitCase(self, aCase):
+. if self.filter.match(aCase.id()):
+. self.suite().addTest(aCase)
+.
+.
+. def main(argv):
+. """To parameterise what tests are run, run this script like so:
+. python test_all.py REGEX
+. i.e.
+. python test_all.py .*Protocol.*
+. to run all tests with Protocol in their id."""
+. if len(argv) > 1:
+. pattern = argv[1]
+. else:
+. pattern = ".*"
+. visitor = filteringVisitor(pattern)
+. test_suite().visit(visitor)
+. runner = ParameterisableTextTestRunner(verbosity=2)
+. runner.resultFactory(earlyStopFactory)
+. if not runner.run(visitor.suite()).wasSuccessful():
+. return 1
+. return 0
+.
+. if __name__ == '__main__':
+. sys.exit(main(sys.argv))
+}
+W
--- testresources-0.1.orig/.bzr/weaves/fa/__init__.py-20050904003059-1490ce87a8faa65b.weave
+++ testresources-0.1/.bzr/weaves/fa/__init__.py-20050904003059-1490ce87a8faa65b.weave
@@ -0,0 +1,77 @@
+# bzr weave file v5
+i
+1 37c5bdfbdcc9386269ab265dc5dd5d83a7c411fd
+n robertc@robertcollins.net-20050904003259-a335a92fb647113f
+
+i 0
+1 7d2ff249455e9c48ef44006b36ac83437a91b736
+n robertc@robertcollins.net-20050904004612-ed91f2dc7ad89cfe
+
+i 1
+1 559ae9dc99c04c46288e1358377316a731365c97
+n robertc@robertcollins.net-20050904005052-0fddf3e7c8d9fd3a
+
+i 2
+1 fb7b29925c19dce24e02104865eea778a3734883
+n robertc@robertcollins.net-20050904071016-083acf76691fed70
+
+i 3
+1 1f4857e1ff113aede48ec6b74751eab2e78d1710
+n robertc@robertcollins.net-20050904072941-fa3cf56d8ea541a3
+
+w
+{ 0
+. #
+. # testresources: extensions to python unittest to allow declaritive use
+. # of resources by test cases.
+. # Copyright (C) 2005 Robert Collins
+. #
+. # This program is free software; you can redistribute it and/or modify
+. # it under the terms of the GNU General Public License as published by
+. # the Free Software Foundation; either version 2 of the License, or
+. # (at your option) any later version.
+. #
+. # This program is distributed in the hope that it will be useful,
+. # but WITHOUT ANY WARRANTY; without even the implied warranty of
+. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+. # GNU General Public License for more details.
+. #
+. # You should have received a copy of the GNU General Public License
+. # along with this program; if not, write to the Free Software
+. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+. #
+.
+{ 1
+. import testresources
+}
+. from testresources.tests import TestUtil
+.
+. def test_suite():
+{ 1
+{ 3
+{ 4
+. import testresources.tests.test_optimising_test_suite
+}
+. import testresources.tests.test_resourced_test_case
+}
+. import testresources.tests.test_test_loader
+}
+{ 2
+. import testresources.tests.test_test_resource
+}
+. result = TestUtil.TestSuite()
+{ 1
+. result.addTest(testresources.tests.test_test_loader.test_suite())
+}
+{ 2
+. result.addTest(testresources.tests.test_test_resource.test_suite())
+}
+{ 3
+. result.addTest(testresources.tests.test_resourced_test_case.test_suite())
+}
+{ 4
+. result.addTest(testresources.tests.test_optimising_test_suite.test_suite())
+}
+. return result
+}
+W
--- testresources-0.1.orig/.bzr/weaves/2c/README-20050904000703-ba3978635caa34f7.weave
+++ testresources-0.1/.bzr/weaves/2c/README-20050904000703-ba3978635caa34f7.weave
@@ -0,0 +1,142 @@
+# bzr weave file v5
+i
+1 9b52805c3a45cd5e97fc4b4da50c8e6e9506db28
+n robertc@robertcollins.net-20050904003259-a335a92fb647113f
+
+i 0
+1 a1162f050a0fe34fbceca62c989c38d79a6918f9
+n robertc@robertcollins.net-20050904004612-ed91f2dc7ad89cfe
+
+i 1
+1 a898dfeda588c8ccbee5f289c9faaacafb502c50
+n robertc@robertcollins.net-20050904010922-869a537b81ebfb20
+
+i 2
+1 ef5e227c19817184fd978e70c84eb5f12096101e
+n robertc@robertcollins.net-20050904014403-6e8106d48aac2f09
+
+i 3
+1 2ff40be427b238c5eb485aa3d5ee87a77f56fc88
+n robertc@robertcollins.net-20050904071016-083acf76691fed70
+
+i 4
+1 88cc9616fbac55575fe45f9880b65f87b2bfa6f5
+n robertc@robertcollins.net-20050904072941-fa3cf56d8ea541a3
+
+i 5
+1 6f08a795ad72b70f292ae861f111aa949f6712ea
+n robertc@robertcollins.net-20050905073000-2a3738a209cd8085
+
+w
+{ 0
+.
+. testresources: extensions to python unittest to allow declaritive use
+. of resources by test cases.
+. Copyright (C) 2005 Robert Collins
+.
+. This program is free software; you can redistribute it and/or modify
+. it under the terms of the GNU General Public License as published by
+. the Free Software Foundation; either version 2 of the License, or
+. (at your option) any later version.
+.
+. This program is distributed in the hope that it will be useful,
+. but WITHOUT ANY WARRANTY; without even the implied warranty of
+. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+. GNU General Public License for more details.
+.
+. You should have received a copy of the GNU General Public License
+. along with this program; if not, write to the Free Software
+. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+.
+.
+. UnitResources is attempting to extend unittest with a clean and simple api to
+. provide test optimisation where expensive common resources are needed for test
+. cases - for example sample working trees for VCS systems, reference databases
+. for enterprise applications, or web servers ... let imagination run wild.
+.
+. How UnitResources works:
+. ========================
+. There are three main components to make UnitResources work:
+. 1) testresources.TestResource
+. A TestResource is a object that tests can use, which provide a getResource()
+. method that returns and object implementing whichever interface the client
+[ 2
+. needs, and which will accept that same object back on its finished() method.
+] 2
+{ 2
+. needs, and which will accept that same object back on its finishedWith()
+. method.
+}
+. Commonly the TestResource will be a class, though that is not a requirement.
+[ 2
+. Most importantly, two getResources with no finished call in the middle, to
+. the same TestResource, should return the same object.
+] 2
+{ 2
+. Most importantly, two getResources with no finishedWith call in the middle,
+. to the same TestResource, should return the same object.
+}
+. XXX the same object requirement may not be needed - but for expensive
+. resources that is the optimisation goal.
+{ 1
+. The goals for TestResources that cannot finish properly are not yet clear,
+. so for now the behaviour will to silently continue.
+}
+. See pydoc testresources.TestResource for details.
+. 2) testresources.OptimisingTestSuite
+. This TestSuite will introspect all the test cases it holds directly and
+. if they declare needed resources, will run the tests in an order that
+. attempts to minimise the number of setup and tear downs required.
+[ 2
+. It attempts to achieve this by callling getResource() and finished() around
+. the sequence of tests that use a specific resource.
+] 2
+{ 2
+. It attempts to achieve this by callling getResource() and finishedWith()
+. around the sequence of tests that use a specific resource.
+}
+.
+. OptimisingTestSuite has a new method over normal TestSuites:
+. adsorbSuite(suite), which scans another test suite and incorporates all of
+. its tests directly into the OptimisingTestSuite. This allows for you to
+. optimise across as broad or small a collection of tests as you wish.
+.
+. 3) testresources.ResourcedTestCase
+. ResourceTestCase can be used as a base class for tests, and when that is
+. done tests will have their _resources attribute automatically checked for
+. resources by both OptimisingTestSuite and their own setUp() and tearDown()
+. methods. (This allows tests to remain functional without needing this
+. specific TestSuite as a container). Alternatively, you can call
+. ResourceTestCase.setUpResources(self) and
+. ResourceTestCase.tearDownResources(self) from your own classes setUp and
+. tearDown and the same behaviour will be activated.
+.
+. Do declare the use of a resource, set _resources as an attribute listing
+. tuples of attribute name, TestResource. During setUp self._attribute_name
+. will be set to TestResource.getResource(), and finsh() will be called for
+. you during tearDown().
+.
+. 4) testresources.TestLoader
+. This is a trivial TestLoader that creates OptimisingTestSuites by default.
+.
+. TODO:
+. * write everything.
+}
+{ 3
+. * resource dirty markers on non current resources - ignore? keep a history ?
+}
+{ 4
+. * test exceptions being raised from _makeResource and _cleanResource
+}
+{ 5
+. * 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.
+}
+{ 6
+. * add a setUpCost field to TestResources
+. * during graph calculation, create a fake root with cost-of-resource paths to
+. all resources, better than choosing an arbitrary node.
+}
+W
--- testresources-0.1.orig/.bzr/weaves/12/test_test_resource.py-20050904005017-576e487dc5544b1c.weave
+++ testresources-0.1/.bzr/weaves/12/test_test_resource.py-20050904005017-576e487dc5544b1c.weave
@@ -0,0 +1,286 @@
+# bzr weave file v5
+i
+1 589b704f66a217cea65d3f93b87aa1fba8949d6b
+n robertc@robertcollins.net-20050904005052-0fddf3e7c8d9fd3a
+
+i 0
+1 9490ec69f8e5733da26757a9515f8360a00f593b
+n robertc@robertcollins.net-20050904010922-869a537b81ebfb20
+
+i 1
+1 708dfee49d2fb6eb186480175c0de7b078aefe2f
+n robertc@robertcollins.net-20050904011543-fc1dc855cee3deaa
+
+i 2
+1 c57ca18744b0966e2ec95998a3fb0963019deb4e
+n robertc@robertcollins.net-20050904013507-2558f957d338d04b
+
+i 3
+1 b77dfb1535fb74083035bffef1a12422a81cbe8d
+n robertc@robertcollins.net-20050904014403-6e8106d48aac2f09
+
+i 4
+1 84574846a2b2259d74aee6b84c2a6f3d93c201c1
+n robertc@robertcollins.net-20050904071016-083acf76691fed70
+
+i 5
+1 02f5556f797059038382b43aaac91958a3143a21
+n robertc@robertcollins.net-20050911111209-ee5da49011cf936a
+
+w
+{ 0
+[ 6
+. #
+] 6
+{ 6
+.
+}
+. # testresources: extensions to python unittest to allow declaritive use
+. # of resources by test cases.
+. # Copyright (C) 2005 Robert Collins
+. #
+. # This program is free software; you can redistribute it and/or modify
+. # it under the terms of the GNU General Public License as published by
+. # the Free Software Foundation; either version 2 of the License, or
+. # (at your option) any later version.
+. #
+. # This program is distributed in the hope that it will be useful,
+. # but WITHOUT ANY WARRANTY; without even the implied warranty of
+. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+. # GNU General Public License for more details.
+. #
+. # You should have received a copy of the GNU General Public License
+. # along with this program; if not, write to the Free Software
+. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+. #
+.
+. import testresources
+. import testresources.tests
+. import unittest
+.
+. def test_suite():
+. loader = testresources.tests.TestUtil.TestLoader()
+. result = loader.loadTestsFromName(__name__)
+. return result
+[ 2
+.
+] 2
+{ 2
+.
+}
+.
+. class TestTestResource(unittest.TestCase):
+.
+. def testImports(self):
+. from testresources import TestResource
+}
+{ 1
+.
+. def testDefaultResource(self):
+[ 5
+. testresources.TestResource._currentResource = None
+. testresources.TestResource._uses = 0
+. resource = testresources.TestResource.getResource()
+] 5
+{ 5
+. self.assertRaises(NotImplementedError,
+. testresources.TestResource.getResource)
+. self.failUnless(hasattr(testresources.TestResource, "_currentResource"))
+. self.failUnless(hasattr(testresources.TestResource, "_uses"))
+. self.failUnless(hasattr(testresources.TestResource, "_dirty"))
+{ 6
+. self.assertEqual(testresources.TestResource.setUpCost, 1)
+. self.assertEqual(testresources.TestResource.tearDownCost, 1)
+}
+. delattr(testresources.TestResource, "_currentResource")
+. delattr(testresources.TestResource, "_uses")
+. delattr(testresources.TestResource, "_dirty")
+.
+. def testSampleResource(self):
+. resource = testresources.SampleTestResource.getResource()
+}
+. self.assertEqual(resource, "You need to implement your own "
+. "getResource.")
+. self.assertEqual(id(resource),
+[ 5
+. id(testresources.TestResource._currentResource))
+. testresources.TestResource._currentResource = None
+. testresources.TestResource._uses = 0
+.
+. def testDefaultFinish(self):
+. testresources.TestResource._currentResource = None
+. testresources.TestResource._uses = 0
+. resource = testresources.TestResource.getResource()
+. testresources.TestResource.finishedWith(resource)
+. self.assertEqual(testresources.TestResource._currentResource, None)
+. self.assertEqual(testresources.TestResource._uses, 0)
+. testresources.TestResource._currentResource = None
+. testresources.TestResource._uses = 0
+] 5
+{ 5
+. id(testresources.SampleTestResource._currentResource))
+{ 6
+. self.assertEqual(testresources.SampleTestResource.setUpCost, 2)
+. self.assertEqual(testresources.SampleTestResource.tearDownCost, 2)
+}
+. self.failIf(hasattr(testresources.TestResource, "_currentResource"))
+. self.failIf(hasattr(testresources.TestResource, "_uses"))
+. self.failIf(hasattr(testresources.TestResource, "_dirty"))
+. testresources.SampleTestResource.finishedWith(resource)
+. self.assertEqual(testresources.SampleTestResource._currentResource,
+. None)
+. self.assertEqual(testresources.SampleTestResource._uses, 0)
+}
+.
+. def testNestedGetAndFinish(self):
+[ 2
+. testresources.TestResource._currentResource = None
+. testresources.TestResource._uses = 0
+. resource = testresources.TestResource.getResource()
+. resource2 = testresources.TestResource.getResource()
+. self.assertEqual(resource2, "You need to implement your own "
+. "getResource.")
+] 2
+{ 2
+[ 5
+. self.doTestNestedGetAndFinish(testresources.TestResource,
+] 5
+{ 5
+. self.doTestNestedGetAndFinish(testresources.SampleTestResource,
+}
+. "You need to implement your own "
+. "getResource.")
+[ 4
+. def doTestNestedGetAndFinish(self, cls, resourcevalue):
+] 4
+{ 4
+. def doTestNestedGetAndFinish(self, cls, resourcevalue, markDirty=False):
+}
+[ 5
+. cls._currentResource = None
+. cls._uses = 0
+] 5
+. resource = cls.getResource()
+. resource2 = cls.getResource()
+. self.assertEqual(resource2, resourcevalue)
+}
+. self.assertEqual(id(resource), id(resource2))
+[ 2
+. self.assertEqual(id(resource2),
+. id(testresources.TestResource._currentResource))
+. testresources.TestResource.finishedWith(resource2)
+. self.assertEqual(id(resource),
+. id(testresources.TestResource._currentResource))
+. testresources.TestResource.finishedWith(resource)
+. self.assertEqual(testresources.TestResource._currentResource, None)
+. self.assertEqual(testresources.TestResource._uses, 0)
+. testresources.TestResource._currentResource = None
+. testresources.TestResource._uses = 0
+}
+] 2
+{ 2
+. self.assertEqual(id(resource2), id(cls._currentResource))
+{ 4
+. if markDirty:
+. cls.dirtied(resource2)
+}
+. cls.finishedWith(resource2)
+. self.assertEqual(id(resource), id(cls._currentResource))
+. cls.finishedWith(resource)
+. self.assertEqual(cls._currentResource, None)
+. self.assertEqual(cls._uses, 0)
+[ 5
+. cls._currentResource = None
+. cls._uses = 0
+] 5
+.
+. def testOverriding_makeResource(self):
+.
+. class MockResource(testresources.TestResource):
+.
+. def _makeResource(self):
+. return "Boo!"
+. _makeResource = classmethod(_makeResource)
+.
+[ 3
+. self.doTestNestedGetAndFinish(MockResource, "Boo!")
+}
+] 3
+{ 3
+. self.doTestNestedGetAndFinish(MockResource, "Boo!")
+.
+. def testOverriding_cleanResource(self):
+.
+. class MockResource(testresources.TestResource):
+.
+. cleans = 0
+. def _cleanResource(self, resource):
+. self.cleans += 1
+. _cleanResource = classmethod(_cleanResource)
+.
+[ 5
+. self.doTestNestedGetAndFinish(MockResource,
+. "You need to implement your own "
+. "getResource.")
+] 5
+{ 5
+. @classmethod
+. def _makeResource(self):
+. return "Boo!"
+.
+. self.doTestNestedGetAndFinish(MockResource, "Boo!")
+}
+. self.assertEqual(MockResource.cleans, 1)
+.
+}
+{ 4
+. def testDirtied(self):
+. class MockResource(testresources.TestResource):
+.
+. cleans = 0
+{ 5
+.
+. @classmethod
+}
+. def _cleanResource(self, resource):
+. self.cleans += 1
+[ 5
+. _cleanResource = classmethod(_cleanResource)
+] 5
+.
+[ 5
+. self.doTestNestedGetAndFinish(MockResource,
+. "You need to implement your own "
+. "getResource.",
+. True)
+] 5
+{ 5
+. @classmethod
+. def _makeResource(self):
+. return "Boo!"
+.
+. self.doTestNestedGetAndFinish(MockResource, "Boo!", True)
+}
+. self.assertEqual(MockResource.cleans, 2)
+}
+{ 5
+.
+. def testTwoResources(self):
+.
+. class MockResource(testresources.TestResource):
+.
+. def _makeResource(self):
+. return "Boo!"
+. _makeResource = classmethod(_makeResource)
+.
+. resource = testresources.SampleTestResource.getResource()
+. resource2 = MockResource.getResource()
+. self.assertEqual(MockResource._uses, 1)
+. self.assertEqual(testresources.SampleTestResource._uses, 1)
+. self.assertNotEqual(id(resource), id(resource2))
+. MockResource.finishedWith(resource2)
+. testresources.SampleTestResource.finishedWith(resource)
+. self.assertEqual(MockResource._uses, 0)
+. self.assertEqual(testresources.SampleTestResource._uses, 0)
+}
+W
--- testresources-0.1.orig/.bzr/weaves/4a/Makefile-20050904000703-8c7d5f80468527b8.weave
+++ testresources-0.1/.bzr/weaves/4a/Makefile-20050904000703-8c7d5f80468527b8.weave
@@ -0,0 +1,17 @@
+# bzr weave file v5
+i
+1 cfaa57582305e84e3188cbefb3d0de43fefeffeb
+n robertc@robertcollins.net-20050904003259-a335a92fb647113f
+
+w
+{ 0
+. PYTHONPATH:=$(shell pwd)/lib:${PYTHONPATH}
+.
+. all:
+.
+. check:
+. PYTHONPATH=$(PYTHONPATH) python ./test_all.py $(TESTRULE)
+.
+. .PHONY: all
+}
+W
--- testresources-0.1.orig/.bzr/weaves/8a/setup.py-20060215013106-15e537740c0ba67d.weave
+++ testresources-0.1/.bzr/weaves/8a/setup.py-20060215013106-15e537740c0ba67d.weave
@@ -0,0 +1,23 @@
+# bzr weave file v5
+i
+1 173b8cf3a5f6316dae8ff67f31ec62ad19c5d651
+n robertc@robertcollins.net-20060215013125-a9198a84b94012bb
+
+w
+{ 0
+. #!/usr/bin/env python
+.
+. from distutils.core import setup
+.
+. setup(name="testresources",
+. version="0.1",
+. description="Testresources, a pyunit extension for managing expensive "
+. "test resources",
+. maintainer="Robert Collins",
+. maintainer_email="robertc@robertcollins.net",
+. url="http://www.robertcollins.net/unittest/testresources",
+. packages=['testresources', 'testresources.tests'],
+. package_dir = {'':'lib'}
+. )
+}
+W
--- testresources-0.1.orig/.bzr/weaves/58/TestUtil.py-20050904003059-9e6e0bd0c114cdac.weave
+++ testresources-0.1/.bzr/weaves/58/TestUtil.py-20050904003059-9e6e0bd0c114cdac.weave
@@ -0,0 +1,98 @@
+# bzr weave file v5
+i
+1 16a90041458e8e80cd807e4affe31efc5c292329
+n robertc@robertcollins.net-20050904003259-a335a92fb647113f
+
+i 0
+1 fbb5fe8e2845869a718c6884a0598c695f52aa18
+n robertc@robertcollins.net-20050904072941-fa3cf56d8ea541a3
+
+w
+{ 0
+. # Copyright (c) 2004 Canonical Limited
+. # Author: Robert Collins
+. #
+. # This program is free software; you can redistribute it and/or modify
+. # it under the terms of the GNU General Public License as published by
+. # the Free Software Foundation; either version 2 of the License, or
+. # (at your option) any later version.
+. #
+. # This program is distributed in the hope that it will be useful,
+. # but WITHOUT ANY WARRANTY; without even the implied warranty of
+. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+. # GNU General Public License for more details.
+. #
+. # You should have received a copy of the GNU General Public License
+. # along with this program; if not, write to the Free Software
+. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+. #
+.
+. import sys
+. import logging
+. import unittest
+.
+.
+. class LogCollector(logging.Handler):
+. def __init__(self):
+. logging.Handler.__init__(self)
+. self.records=[]
+. def emit(self, record):
+. self.records.append(record.getMessage())
+.
+.
+. def makeCollectingLogger():
+. """I make a logger instance that collects its logs for programmatic analysis
+. -> (logger, collector)"""
+. logger=logging.Logger("collector")
+. handler=LogCollector()
+. handler.setFormatter(logging.Formatter("%(levelname)s: %(message)s"))
+. logger.addHandler(handler)
+. return logger, handler
+.
+.
+. def visitTests(suite, visitor):
+. """A foreign method for visiting the tests in a test suite."""
+{ 1
+. if isinstance(suite, unittest.TestCase):
+. visitor.visitCase(suite)
+. return
+}
+. for test in suite._tests:
+. #Abusing types to avoid monkey patching unittest.TestCase.
+. # Maybe that would be better?
+. try:
+. test.visit(visitor)
+. except AttributeError:
+. if isinstance(test, unittest.TestCase):
+. visitor.visitCase(test)
+. elif isinstance(test, unittest.TestSuite):
+. visitor.visitSuite(test)
+. visitTests(test, visitor)
+. else:
+. print "unvisitable non-unittest.TestCase element %r (%r)" % (test, test.__class__)
+.
+.
+. class TestSuite(unittest.TestSuite):
+. """I am an extended TestSuite with a visitor interface.
+. This is primarily to allow filtering of tests - and suites or
+. more in the future. An iterator of just tests wouldn't scale..."""
+.
+. def visit(self, visitor):
+. """visit the composite. Visiting is depth-first.
+. current callbacks are visitSuite and visitCase."""
+. visitor.visitSuite(self)
+. visitTests(self, visitor)
+.
+.
+. class TestLoader(unittest.TestLoader):
+. """Custome TestLoader to set the right TestSuite class."""
+. suiteClass = TestSuite
+.
+. class TestVisitor(object):
+. """A visitor for Tests"""
+. def visitSuite(self, aTestSuite):
+. pass
+. def visitCase(self, aTestCase):
+. pass
+}
+W
--- testresources-0.1.orig/.bzr/stat-cache
+++ testresources-0.1/.bzr/stat-cache
@@ -0,0 +1,15 @@
+### bzr hashcache v5
+lib/testresources/priodict.py// 86e43bf1bafbd1d96275bb3b5955f4df40872092 2764 1125825020 1139967150 6753666 769 33188
+test_all.py// b6c3d6f6c2915dfdce50b09152c2ba9cc73edf67 3953 1125793494 1139967151 6095715 769 33252
+lib/testresources/tests/test_resourced_test_case.py// dad996192dc2756d667bbc1df23ca15a32a40c34 3469 1125817782 1139967150 6735704 769 33188
+Makefile// cfaa57582305e84e3188cbefb3d0de43fefeffeb 129 1125113450 1139967150 6095713 769 33188
+lib/testresources/tests/__init__.py// 1f4857e1ff113aede48ec6b74751eab2e78d1710 1533 1125818075 1139967150 6734213 769 33188
+lib/testresources/tests/test_optimising_test_suite.py// 7a22d8afd4bcf55b2942b716851b93d0b8813983 6369 1139966749 1139967150 6735715 769 33188
+lib/testresources/tests/test_test_loader.py// 11ca4960996e9ff528187cdd26dc8b3eee79b150 1317 1125794863 1139967150 6735067 769 33188
+lib/testresources/tests/TestUtil.py// fbb5fe8e2845869a718c6884a0598c695f52aa18 2886 1125818926 1139967150 6734212 769 33188
+lib/testresources/__init__.py// bc8e3c119c6c28b4b3ea58a47e8cf9403520a541 7323 1139966749 1139967150 6753662 769 33188
+COPYING// dfac199a7539a404407098a2541b9482279f690d 17992 1125113740 1139967151 6095745 769 33188
+README// 6f08a795ad72b70f292ae861f111aa949f6712ea 4349 1125863200 1139967151 6095782 769 33188
+setup.py// 173b8cf3a5f6316dae8ff67f31ec62ad19c5d651 468 1139967078 1139967151 6095874 769 33261
+lib/testresources/tests/test_test_resource.py// 02f5556f797059038382b43aaac91958a3143a21 5612 1126437114 1139967150 6734218 769 33188
+lib/testresources/dijkstra.py// 82608e711ae39ce280c360e644c3f4b9b4742f12 3668 1125825034 1139967150 6753665 769 33188
--- testresources-0.1.orig/.bzr/basis-inventory.robertc@robertcollins.net-20060215013125-a9198a84b94012bb
+++ testresources-0.1/.bzr/basis-inventory.robertc@robertcollins.net-20060215013125-a9198a84b94012bb
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--- testresources-0.1.orig/debian/rules
+++ testresources-0.1/debian/rules
@@ -0,0 +1,13 @@
+#!/usr/bin/make -f
+
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/class/python-distutils.mk
+
+DEB_PYTHON_COMPILE_VERSION=2.4
+
+clean::
+ -rm -rf build
+ find . -name "*.pyc" -print0 | xargs -0 rm -f
+
+common-post-build-indep::
+ PYTHONPATH=lib ./test_all.py
--- testresources-0.1.orig/debian/control
+++ testresources-0.1/debian/control
@@ -0,0 +1,16 @@
+Source: testresources
+Section: devel
+Priority: optional
+Maintainer: Robert Collins
+Build-Depends: debhelper (>= 5), cdbs
+Build-Depends-Indep: python2.4-docutils, python2.4, python2.4-dev
+Standards-Version: 3.6.2
+
+Package: python2.4-testresources
+Architecture: all
+Depends: python2.4
+Description: testresources, a PyUnit extension for managing expensive test fixtures.
+ PyUnit extension to manage the initialisation and lifetime of expensive test
+ fixtures. For exmaple reference databases are often only need to be constructed
+ once but standard test isolation causes them to be constructed for every fixture,
+ making test execution very slow.
--- testresources-0.1.orig/debian/compat
+++ testresources-0.1/debian/compat
@@ -0,0 +1 @@
+5
--- testresources-0.1.orig/debian/changelog
+++ testresources-0.1/debian/changelog
@@ -0,0 +1,15 @@
+testresources (0.1-1.1) unstable; urgency=medium
+
+ * Non-maintainer upload.
+ * setup.py, test_all.py: Use python2.4 as the interpreter.
+ Closes: #358403.
+ * Move build dependencies used in the clean target to Build-Depends.
+ * Build depend on debhelper (>= 5) since we use v5 mode.
+
+ -- Matej Vela Fri, 19 May 2006 12:58:19 -0500
+
+testresources (0.1-1) unstable; urgency=low
+
+ * Initial release. Closes: #353378
+
+ -- Robert Collins Wed, 15 Feb 2006 12:36:57 +1100
--- testresources-0.1.orig/debian/copyright
+++ testresources-0.1/debian/copyright
@@ -0,0 +1,26 @@
+This package was originally debianized by Robert Collins
+ on Web, 15 Feb 2006.
+
+It was downloaded from http://www.robertcollins.net/unittest/testresources.
+
+Upstream Authors: Robert Collins
+
+Copyright 2005 Robert Collins.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License with
+the Debian GNU/Linux distribution in file /usr/share/common-licenses/GPL;
+if not, write to the Free Software Foundation, Inc., 51 Franklin St,
+Fifth Floor, Boston, MA 02110-1301, USA.
+
+On Debian systems, the full text of the GPL can be found in
+/usr/share/common-licenses/GPL
--- testresources-0.1.orig/debian/NEWS
+++ testresources-0.1/debian/NEWS
@@ -0,0 +1,6 @@
+testresources (0.1-1) unstable; urgency=low
+
+ * Initial packaging of test resources.
+
+ -- Robert Collins Wed, 15 Feb 2006 12:36:57 +1100
+
--- testresources-0.1.orig/debian/testresources.install
+++ testresources-0.1/debian/testresources.install
@@ -0,0 +1,2 @@
+debian/tmp/usr/bin/*
+debian/tmp/usr/lib/*
--- testresources-0.1.orig/.bzr-shelf
+++ testresources-0.1/.bzr-shelf
@@ -0,0 +1,114 @@
+--- lib/testresources/__init__.py
++++ lib/testresources/__init__.py
+@@ -85,13 +85,27 @@
+ # are quite arbitrary and can thus make things less than
+ # optimal.
+ from testresources.dijkstra import Dijkstra
++ # do not try to seed with None, it does not work.
++ # see the graph with the entry costs to get any test up.
++ graph[1]={}
++ for test in graph.keys():
++ if test is 1:
++ continue
++ up_costs = [resource[1].setUpCost for resource in test._resources]
++ graph[1][test] = sum(up_costs)
++ down_costs = [resource[1].tearDownCost for resource
++ in test._resources]
++ graph[test][1] = sum(down_costs)
+ if len(graph.keys()) > 0:
+- distances, predecessors = Dijkstra(graph, graph.keys()[0])
++ distances, predecessors = Dijkstra(graph, 1)
++ ## print "D", distances
++ ## print "P", predecessors
+ # and sort by distance
+ nodes = distances.items()
+ nodes.sort(key=lambda x:x[1])
+ for test, distance in nodes:
+- sorted.append(test)
++ if test is not 1:
++ sorted.append(test)
+ self._tests = sorted + legacy
+
+ def _getGraph(self):
+@@ -113,13 +127,19 @@
+ graph[test] = {}
+ while len(pending):
+ test = pending.pop()
+- test_resources = set(test._resources)
++ test_resources = set(resource[1] for resource in test._resources)
+ for othertest in pending:
+- othertest_resources = set(othertest._resources)
+- cost = len(test_resources.symmetric_difference(
+- othertest_resources))
+- graph[test][othertest] = cost
+- graph[othertest][test] = cost
++ othertest_resources = set(resource[1] for resource in
++ othertest._resources)
++ going = test_resources.difference(othertest_resources)
++ incoming = othertest_resources.difference(test_resources)
++ to_cost = (sum([resource.tearDownCost for resource in going]) +
++ sum([resource.setUpCost for resource in incoming]))
++ from_cost = (sum([resource.setUpCost for resource in going]) +
++ sum([resource.tearDownCost for resource in
++ incoming]))
++ graph[test][othertest] = to_cost
++ graph[othertest][test] = from_cost
+ return graph, legacy
+
+
+--- lib/testresources/tests/test_optimising_test_suite.py
++++ lib/testresources/tests/test_optimising_test_suite.py
+@@ -127,13 +127,16 @@
+ pass
+
+ class ResourceOne(testresources.TestResource):
+- pass
++ setUpCost = 1
++ tearDownCost = 2
+
+ class ResourceTwo(testresources.TestResource):
+- pass
++ setUpCost = 4
++ tearDownCost = 8
+
+ class ResourceThree(testresources.TestResource):
+- pass
++ setUpCost = 16
++ tearDownCost = 32
+
+ self.suite = testresources.OptimisingTestSuite()
+ self.case1 = MockTest("test_one")
+@@ -146,22 +149,23 @@
+ self.case3._resources = [("_three", ResourceThree)]
+ self.case4 = MockTest("test_four")
+ self.suite.addTests([self.case3, self.case1, self.case4, self.case2])
+- # acceptable sorted orders are:
+- # 1, 2, 3, 4
+- # 3, 2, 1, 4
+-
++ # acceptable sort orders at the moment are:
++ # 2, 3, 1, 4 = 20 + 8 + 37 = 65 (graph seek from 2)
++ # 1, 2, 3, 4 = 5 + 18 + 8 + 32 = 63 (graph seek from 1)
++ # 1, 3, 2, 4 = 5 + 26 + 4 + 40 = 75
++ #
++
+ def testBasicSortTests(self):
+ self.suite.sortTests()
+- self.failUnless(self.suite._tests == [self.case1, self.case2,
+- self.case3, self.case4] or
+- self.suite._tests == [self.case3, self.case2,
++ print self.suite._tests
++ self.failUnless(self.suite._tests == [self.case2, self.case3,
+ self.case1, self.case4])
+
+ def testGetGraph(self):
+ graph, legacy = self.suite._getGraph()
+- case1vertex = {self.case2:2, self.case3:3}
+- case2vertex = {self.case1:2, self.case3:1}
+- case3vertex = {self.case1:3, self.case2:1}
++ case1vertex = {self.case2:18, self.case3:26}
++ case2vertex = {self.case1:33, self.case3:8}
++ case3vertex = {self.case1:37, self.case2:4}
+ self.assertEqual(legacy, [self.case4])
+ self.assertEqual(graph[self.case1], case1vertex)
+ self.assertEqual(graph[self.case2], case2vertex)