summaryrefslogtreecommitdiff
path: root/NOTES
blob: 54c0ddfc3f36f2cb811196dfb0458d4f8d9c636d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
notes on loading from modules

this pretty much all has to take place inside of the _tests iterator.


if the module is wanted
   run setup
   load tests (including submodules) and yield each test
   run teardown
else if the module is not wanted:
   * do not import the module *
   if the module is a package:
      recurse into the package looking for test modules


make suite.TestSuite
put run, call, setup, teardown, shortdescription there

make LazySuite subclass it

get rid of TestModule

do module import in loadTestsFromModuleName; if an error, pass the error
to the module suite, whose run() should re-raise the error so that import
errors are seen only when we actually try to run the tests

make ModuleSuite class with setUp, tearDown doing try_run, it gets
additional module and error keyword args

rename TestDir to DirectorySuite

try to make things less stateful

 - conf should be immutable?
 - certainly conf.working_dir shouldn't change, or if it does it has to be a
   stack
 - things that are mutable should be removed from conf and passed separately

tests and working dir should come out of conf and be passed to loader and
selector

loader.loadTestsFromNames(names, module=None, working_dir=None)
 -> split and absolutize all of the test names
 -> give them to the selector (self.selector.tests = names)
 -> start walking at working_dir
 -> sort dirnames into test-last order
 -> yield loadFromName for wanted files
    -> ModuleSuite
 -> for directories:
    - keep descending if wanted and not a package
    - remove from list if not wanted
    - if a package, yield loadFromName for package
      -> ModuleSuite
      -> since module has a path, we need to restart the walk
         and call loadTestsFromNames with the path end as the working dir
         but we want to do that lazily, so we need to bundle up the
         needed information into a callable and a LazySuite

loader.collectTests(working_dir, names=[]):
 -> yield each test suite as found


suites:

ModuleSuite
ClassSuite
TestCaseSuite
GeneratorSuite
GeneratorMethodSuite


*
proxy suite may need to be mixed in by the collector when running under test
or, suite base class has a testProxy property, which if not None is called to
proxy the test

*
module isolation plugin will break under depth-first loading. how to restore
it:

preImport hook
 - snapshot sys.modules: this is what to restore AFTER processing of the
   test module is complete
postImport hook
 - snapshot sys.modules: this is what to restore BEFORE running module tests
startTest
 - if isa module, restore postImport sys.modules snapshot
stopTest
 - if isa module, restore preImport sys.modules snapshot