Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: third_party/twisted_8_1/twisted/trial/test/test_output.py

Issue 12261012: Remove third_party/twisted_8_1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 from twisted.scripts import trial
2 from twisted.trial import runner
3 from twisted.trial.test import packages
4 import os, sys, StringIO
5
6
7 def runTrial(*args):
8 from twisted.trial import reporter
9 config = trial.Options()
10 config.parseOptions(args)
11 output = StringIO.StringIO()
12 myRunner = runner.TrialRunner(
13 reporter.VerboseTextReporter,
14 stream=output,
15 workingDirectory=config['temp-directory'])
16 suite = trial._getSuite(config)
17 result = myRunner.run(suite)
18 return output.getvalue()
19
20
21 class TestImportErrors(packages.SysPathManglingTest):
22 """Actually run trial as if on the command line and check that the output
23 is what we expect.
24 """
25
26 debug = False
27 parent = "_testImportErrors"
28 def runTrial(self, *args):
29 return runTrial('--temp-directory', self.mktemp(), *args)
30
31 def _print(self, stuff):
32 print stuff
33 return stuff
34
35 def failUnlessIn(self, container, containee, *args, **kwargs):
36 # redefined to be useful in callbacks
37 super(TestImportErrors, self).failUnlessIn(
38 containee, container, *args, **kwargs)
39 return container
40
41 def failIfIn(self, container, containee, *args, **kwargs):
42 # redefined to be useful in callbacks
43 super(TestImportErrors, self).failIfIn(
44 containee, container, *args, **kwargs)
45 return container
46
47 def test_trialRun(self):
48 self.runTrial()
49
50 def test_nonexistentModule(self):
51 d = self.runTrial('twisted.doesntexist')
52 self.failUnlessIn(d, '[ERROR]')
53 self.failUnlessIn(d, 'twisted.doesntexist')
54 return d
55
56 def test_nonexistentPackage(self):
57 d = self.runTrial('doesntexist')
58 self.failUnlessIn(d, 'doesntexist')
59 self.failUnlessIn(d, 'ValueError')
60 self.failUnlessIn(d, '[ERROR]')
61 return d
62
63 def test_nonexistentPackageWithModule(self):
64 d = self.runTrial('doesntexist.barney')
65 self.failUnlessIn(d, 'doesntexist.barney')
66 self.failUnlessIn(d, 'ValueError')
67 self.failUnlessIn(d, '[ERROR]')
68 return d
69
70 def test_badpackage(self):
71 d = self.runTrial('badpackage')
72 self.failUnlessIn(d, '[ERROR]')
73 self.failUnlessIn(d, 'badpackage')
74 self.failIfIn(d, 'IOError')
75 return d
76
77 def test_moduleInBadpackage(self):
78 d = self.runTrial('badpackage.test_module')
79 self.failUnlessIn(d, "[ERROR]")
80 self.failUnlessIn(d, "badpackage.test_module")
81 self.failIfIn(d, 'IOError')
82 return d
83
84 def test_badmodule(self):
85 d = self.runTrial('package.test_bad_module')
86 self.failUnlessIn(d, '[ERROR]')
87 self.failUnlessIn(d, 'package.test_bad_module')
88 self.failIfIn(d, 'IOError')
89 self.failIfIn(d, '<module ')
90 return d
91
92 def test_badimport(self):
93 d = self.runTrial('package.test_import_module')
94 self.failUnlessIn(d, '[ERROR]')
95 self.failUnlessIn(d, 'package.test_import_module')
96 self.failIfIn(d, 'IOError')
97 self.failIfIn(d, '<module ')
98 return d
99
100 def test_recurseImport(self):
101 d = self.runTrial('package')
102 self.failUnlessIn(d, '[ERROR]')
103 self.failUnlessIn(d, 'test_bad_module')
104 self.failUnlessIn(d, 'test_import_module')
105 self.failIfIn(d, '<module ')
106 self.failIfIn(d, 'IOError')
107 return d
108
109 def test_recurseImportErrors(self):
110 d = self.runTrial('package2')
111 self.failUnlessIn(d, '[ERROR]')
112 self.failUnlessIn(d, 'package2')
113 self.failUnlessIn(d, 'test_module')
114 self.failUnlessIn(d, "No module named frotz")
115 self.failIfIn(d, '<module ')
116 self.failIfIn(d, 'IOError')
117 return d
118
119 def test_nonRecurseImportErrors(self):
120 d = self.runTrial('-N', 'package2')
121 self.failUnlessIn(d, '[ERROR]')
122 self.failUnlessIn(d, "No module named frotz")
123 self.failIfIn(d, '<module ')
124 return d
125
126 def test_regularRun(self):
127 d = self.runTrial('package.test_module')
128 self.failIfIn(d, '[ERROR]')
129 self.failIfIn(d, 'IOError')
130 self.failUnlessIn(d, 'OK')
131 self.failUnlessIn(d, 'PASSED (successes=1)')
132 return d
133
134 def test_filename(self):
135 self.mangleSysPath(self.oldPath)
136 d = self.runTrial(
137 os.path.join(self.parent, 'package', 'test_module.py'))
138 self.failIfIn(d, '[ERROR]')
139 self.failIfIn(d, 'IOError')
140 self.failUnlessIn(d, 'OK')
141 self.failUnlessIn(d, 'PASSED (successes=1)')
142 return d
143
144 def test_dosFile(self):
145 ## XXX -- not really an output test, more of a script test
146 self.mangleSysPath(self.oldPath)
147 d = self.runTrial(
148 os.path.join(self.parent,
149 'package', 'test_dos_module.py'))
150 self.failIfIn(d, '[ERROR]')
151 self.failIfIn(d, 'IOError')
152 self.failUnlessIn(d, 'OK')
153 self.failUnlessIn(d, 'PASSED (successes=1)')
154 return d
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698