bee_python 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (503) hide show
  1. data/LICENSE +202 -0
  2. data/build/README +23 -0
  3. data/egg/egg/build.yml +70 -0
  4. data/egg/egg/ez_setup.py +280 -0
  5. data/egg/egg/script.py +12 -0
  6. data/egg/egg/setup.erb +11 -0
  7. data/egg/egg/suite.py +37 -0
  8. data/egg/egg/test.py +31 -0
  9. data/egg/egg.yml +69 -0
  10. data/egg/http/build.erb +53 -0
  11. data/egg/http/server.py +34 -0
  12. data/egg/http.yml +50 -0
  13. data/egg/mysql/mysql.py +43 -0
  14. data/egg/mysql.yml +44 -0
  15. data/egg/project/build.erb +77 -0
  16. data/egg/project/script.py +42 -0
  17. data/egg/project/test.py +31 -0
  18. data/egg/project.yml +59 -0
  19. data/egg/script/build.erb +35 -0
  20. data/egg/script/script.py +42 -0
  21. data/egg/script.yml +50 -0
  22. data/egg/soap/build.erb +52 -0
  23. data/egg/soap/client.py +18 -0
  24. data/egg/soap/server.py +30 -0
  25. data/egg/soap.yml +58 -0
  26. data/egg/source/source.py +42 -0
  27. data/egg/source.yml +47 -0
  28. data/egg/test/test.py +28 -0
  29. data/egg/test.yml +44 -0
  30. data/egg/xmlrpc/build.erb +52 -0
  31. data/egg/xmlrpc/client.py +22 -0
  32. data/egg/xmlrpc/server.py +24 -0
  33. data/egg/xmlrpc.yml +51 -0
  34. data/lib/bee_task_python.rb +390 -0
  35. data/test/build.yml +16 -0
  36. data/test/tc_bee_task_python.rb +27 -0
  37. data/test/test_build.rb +26 -0
  38. data/test/test_build_listener.rb +62 -0
  39. data/test/ts_bee_python.rb +26 -0
  40. data/tools/common/__init__.py +5 -0
  41. data/tools/common/common/__init__.py +140 -0
  42. data/tools/common/common/__pkginfo__.py +43 -0
  43. data/tools/common/common/adbh.py +35 -0
  44. data/tools/common/common/cache.py +114 -0
  45. data/tools/common/common/changelog.py +234 -0
  46. data/tools/common/common/clcommands.py +181 -0
  47. data/tools/common/common/cli.py +212 -0
  48. data/tools/common/common/compat.py +328 -0
  49. data/tools/common/common/configuration.py +1087 -0
  50. data/tools/common/common/contexts.py +58 -0
  51. data/tools/common/common/corbautils.py +117 -0
  52. data/tools/common/common/daemon.py +171 -0
  53. data/tools/common/common/date.py +279 -0
  54. data/tools/common/common/db.py +49 -0
  55. data/tools/common/common/dbf.py +229 -0
  56. data/tools/common/common/debugger.py +208 -0
  57. data/tools/common/common/decorators.py +190 -0
  58. data/tools/common/common/deprecation.py +118 -0
  59. data/tools/common/common/fileutils.py +409 -0
  60. data/tools/common/common/graph.py +259 -0
  61. data/tools/common/common/html.py +142 -0
  62. data/tools/common/common/interface.py +76 -0
  63. data/tools/common/common/logging_ext.py +166 -0
  64. data/tools/common/common/modutils.py +670 -0
  65. data/tools/common/common/optik_ext.py +383 -0
  66. data/tools/common/common/optparser.py +92 -0
  67. data/tools/common/common/pdf_ext.py +111 -0
  68. data/tools/common/common/proc.py +276 -0
  69. data/tools/common/common/pyro_ext.py +146 -0
  70. data/tools/common/common/pytest.py +754 -0
  71. data/tools/common/common/shellutils.py +383 -0
  72. data/tools/common/common/sphinx_ext.py +87 -0
  73. data/tools/common/common/sphinxutils.py +122 -0
  74. data/tools/common/common/sqlgen.py +31 -0
  75. data/tools/common/common/table.py +930 -0
  76. data/tools/common/common/tasksqueue.py +97 -0
  77. data/tools/common/common/test/__init__.py +1 -0
  78. data/tools/common/common/test/data/ChangeLog +184 -0
  79. data/tools/common/common/test/data/MyPyPa-0.1.0-py2.5.egg +0 -0
  80. data/tools/common/common/test/data/__init__.py +1 -0
  81. data/tools/common/common/test/data/content_differ_dir/NOTHING +0 -0
  82. data/tools/common/common/test/data/content_differ_dir/README +1 -0
  83. data/tools/common/common/test/data/content_differ_dir/subdir/coin +1 -0
  84. data/tools/common/common/test/data/content_differ_dir/subdir/toto.txt +53 -0
  85. data/tools/common/common/test/data/file_differ_dir/NOTHING +0 -0
  86. data/tools/common/common/test/data/file_differ_dir/README +1 -0
  87. data/tools/common/common/test/data/file_differ_dir/subdir/toto.txt +53 -0
  88. data/tools/common/common/test/data/file_differ_dir/subdirtwo/Hello +0 -0
  89. data/tools/common/common/test/data/find_test/__init__.py +0 -0
  90. data/tools/common/common/test/data/find_test/foo.txt +0 -0
  91. data/tools/common/common/test/data/find_test/module.py +0 -0
  92. data/tools/common/common/test/data/find_test/module2.py +0 -0
  93. data/tools/common/common/test/data/find_test/newlines.txt +0 -0
  94. data/tools/common/common/test/data/find_test/noendingnewline.py +0 -0
  95. data/tools/common/common/test/data/find_test/nonregr.py +0 -0
  96. data/tools/common/common/test/data/find_test/normal_file.txt +0 -0
  97. data/tools/common/common/test/data/find_test/spam.txt +0 -0
  98. data/tools/common/common/test/data/find_test/sub/doc.txt +0 -0
  99. data/tools/common/common/test/data/find_test/sub/momo.py +0 -0
  100. data/tools/common/common/test/data/find_test/test.ini +0 -0
  101. data/tools/common/common/test/data/find_test/test1.msg +0 -0
  102. data/tools/common/common/test/data/find_test/test2.msg +0 -0
  103. data/tools/common/common/test/data/find_test/write_protected_file.txt +0 -0
  104. data/tools/common/common/test/data/foo.txt +9 -0
  105. data/tools/common/common/test/data/module.py +88 -0
  106. data/tools/common/common/test/data/module2.py +77 -0
  107. data/tools/common/common/test/data/newlines.txt +3 -0
  108. data/tools/common/common/test/data/noendingnewline.py +36 -0
  109. data/tools/common/common/test/data/nonregr.py +14 -0
  110. data/tools/common/common/test/data/normal_file.txt +0 -0
  111. data/tools/common/common/test/data/reference_dir/NOTHING +0 -0
  112. data/tools/common/common/test/data/reference_dir/README +1 -0
  113. data/tools/common/common/test/data/reference_dir/subdir/coin +1 -0
  114. data/tools/common/common/test/data/reference_dir/subdir/toto.txt +53 -0
  115. data/tools/common/common/test/data/same_dir/NOTHING +0 -0
  116. data/tools/common/common/test/data/same_dir/README +1 -0
  117. data/tools/common/common/test/data/same_dir/subdir/coin +1 -0
  118. data/tools/common/common/test/data/same_dir/subdir/toto.txt +53 -0
  119. data/tools/common/common/test/data/spam.txt +9 -0
  120. data/tools/common/common/test/data/sub/doc.txt +1 -0
  121. data/tools/common/common/test/data/sub/momo.py +1 -0
  122. data/tools/common/common/test/data/subdir_differ_dir/NOTHING +0 -0
  123. data/tools/common/common/test/data/subdir_differ_dir/README +1 -0
  124. data/tools/common/common/test/data/subdir_differ_dir/subdir/coin +1 -0
  125. data/tools/common/common/test/data/subdir_differ_dir/subdir/toto.txt +53 -0
  126. data/tools/common/common/test/data/test.ini +20 -0
  127. data/tools/common/common/test/data/test1.msg +30 -0
  128. data/tools/common/common/test/data/test2.msg +42 -0
  129. data/tools/common/common/test/data/write_protected_file.txt +0 -0
  130. data/tools/common/common/test/foomod.py +17 -0
  131. data/tools/common/common/test/unittest_cache.py +129 -0
  132. data/tools/common/common/test/unittest_changelog.py +37 -0
  133. data/tools/common/common/test/unittest_compat.py +239 -0
  134. data/tools/common/common/test/unittest_configuration.py +348 -0
  135. data/tools/common/common/test/unittest_date.py +154 -0
  136. data/tools/common/common/test/unittest_decorators.py +62 -0
  137. data/tools/common/common/test/unittest_deprecation.py +76 -0
  138. data/tools/common/common/test/unittest_fileutils.py +133 -0
  139. data/tools/common/common/test/unittest_graph.py +50 -0
  140. data/tools/common/common/test/unittest_html.py +76 -0
  141. data/tools/common/common/test/unittest_interface.py +87 -0
  142. data/tools/common/common/test/unittest_modutils.py +244 -0
  143. data/tools/common/common/test/unittest_pytest.py +50 -0
  144. data/tools/common/common/test/unittest_shellutils.py +248 -0
  145. data/tools/common/common/test/unittest_table.py +448 -0
  146. data/tools/common/common/test/unittest_taskqueue.py +71 -0
  147. data/tools/common/common/test/unittest_testlib.py +956 -0
  148. data/tools/common/common/test/unittest_textutils.py +247 -0
  149. data/tools/common/common/test/unittest_tree.py +248 -0
  150. data/tools/common/common/test/unittest_umessage.py +55 -0
  151. data/tools/common/common/test/unittest_ureports_html.py +64 -0
  152. data/tools/common/common/test/unittest_ureports_text.py +105 -0
  153. data/tools/common/common/test/unittest_xmlutils.py +75 -0
  154. data/tools/common/common/test/utils.py +87 -0
  155. data/tools/common/common/testlib.py +1927 -0
  156. data/tools/common/common/textutils.py +476 -0
  157. data/tools/common/common/tree.py +372 -0
  158. data/tools/common/common/umessage.py +161 -0
  159. data/tools/common/common/ureports/__init__.py +174 -0
  160. data/tools/common/common/ureports/docbook_writer.py +139 -0
  161. data/tools/common/common/ureports/html_writer.py +131 -0
  162. data/tools/common/common/ureports/nodes.py +201 -0
  163. data/tools/common/common/ureports/text_writer.py +140 -0
  164. data/tools/common/common/vcgutils.py +216 -0
  165. data/tools/common/common/visitor.py +107 -0
  166. data/tools/common/common/xmlrpcutils.py +136 -0
  167. data/tools/common/common/xmlutils.py +61 -0
  168. data/tools/compile/compile.py +16 -0
  169. data/tools/coverage/coverage.py +602 -0
  170. data/tools/epydoc/__init__.py +227 -0
  171. data/tools/epydoc/__init__.pyc +0 -0
  172. data/tools/epydoc/apidoc.py +2203 -0
  173. data/tools/epydoc/apidoc.pyc +0 -0
  174. data/tools/epydoc/checker.py +349 -0
  175. data/tools/epydoc/checker.pyc +0 -0
  176. data/tools/epydoc/cli.py +1470 -0
  177. data/tools/epydoc/cli.pyc +0 -0
  178. data/tools/epydoc/compat.py +250 -0
  179. data/tools/epydoc/compat.pyc +0 -0
  180. data/tools/epydoc/docbuilder.py +1358 -0
  181. data/tools/epydoc/docbuilder.pyc +0 -0
  182. data/tools/epydoc/docintrospecter.py +1056 -0
  183. data/tools/epydoc/docintrospecter.pyc +0 -0
  184. data/tools/epydoc/docparser.py +2113 -0
  185. data/tools/epydoc/docparser.pyc +0 -0
  186. data/tools/epydoc/docstringparser.py +1111 -0
  187. data/tools/epydoc/docstringparser.pyc +0 -0
  188. data/tools/epydoc/docwriter/__init__.py +12 -0
  189. data/tools/epydoc/docwriter/__init__.pyc +0 -0
  190. data/tools/epydoc/docwriter/dotgraph.py +1351 -0
  191. data/tools/epydoc/docwriter/dotgraph.pyc +0 -0
  192. data/tools/epydoc/docwriter/html.py +3491 -0
  193. data/tools/epydoc/docwriter/html.pyc +0 -0
  194. data/tools/epydoc/docwriter/html_colorize.py +909 -0
  195. data/tools/epydoc/docwriter/html_colorize.pyc +0 -0
  196. data/tools/epydoc/docwriter/html_css.py +550 -0
  197. data/tools/epydoc/docwriter/html_css.pyc +0 -0
  198. data/tools/epydoc/docwriter/html_help.py +190 -0
  199. data/tools/epydoc/docwriter/html_help.pyc +0 -0
  200. data/tools/epydoc/docwriter/latex.py +1187 -0
  201. data/tools/epydoc/docwriter/latex.pyc +0 -0
  202. data/tools/epydoc/docwriter/plaintext.py +276 -0
  203. data/tools/epydoc/docwriter/plaintext.pyc +0 -0
  204. data/tools/epydoc/docwriter/xlink.py +505 -0
  205. data/tools/epydoc/docwriter/xlink.pyc +0 -0
  206. data/tools/epydoc/gui.py +1148 -0
  207. data/tools/epydoc/gui.pyc +0 -0
  208. data/tools/epydoc/log.py +204 -0
  209. data/tools/epydoc/log.pyc +0 -0
  210. data/tools/epydoc/markup/__init__.py +623 -0
  211. data/tools/epydoc/markup/__init__.pyc +0 -0
  212. data/tools/epydoc/markup/doctest.py +311 -0
  213. data/tools/epydoc/markup/doctest.pyc +0 -0
  214. data/tools/epydoc/markup/epytext.py +2116 -0
  215. data/tools/epydoc/markup/epytext.pyc +0 -0
  216. data/tools/epydoc/markup/javadoc.py +250 -0
  217. data/tools/epydoc/markup/javadoc.pyc +0 -0
  218. data/tools/epydoc/markup/plaintext.py +78 -0
  219. data/tools/epydoc/markup/plaintext.pyc +0 -0
  220. data/tools/epydoc/markup/pyval_repr.py +532 -0
  221. data/tools/epydoc/markup/pyval_repr.pyc +0 -0
  222. data/tools/epydoc/markup/restructuredtext.py +906 -0
  223. data/tools/epydoc/markup/restructuredtext.pyc +0 -0
  224. data/tools/epydoc/test/__init__.py +97 -0
  225. data/tools/epydoc/test/__init__.pyc +0 -0
  226. data/tools/epydoc/test/util.py +226 -0
  227. data/tools/epydoc/test/util.pyc +0 -0
  228. data/tools/epydoc/util.py +289 -0
  229. data/tools/epydoc/util.pyc +0 -0
  230. data/tools/logilab/logilab/__init__.py +5 -0
  231. data/tools/logilab/logilab/astng/__init__.py +82 -0
  232. data/tools/logilab/logilab/astng/__pkginfo__.py +76 -0
  233. data/tools/logilab/logilab/astng/_exceptions.py +64 -0
  234. data/tools/logilab/logilab/astng/_nodes_ast.py +667 -0
  235. data/tools/logilab/logilab/astng/_nodes_compiler.py +758 -0
  236. data/tools/logilab/logilab/astng/bases.py +608 -0
  237. data/tools/logilab/logilab/astng/builder.py +239 -0
  238. data/tools/logilab/logilab/astng/inference.py +426 -0
  239. data/tools/logilab/logilab/astng/inspector.py +289 -0
  240. data/tools/logilab/logilab/astng/manager.py +421 -0
  241. data/tools/logilab/logilab/astng/mixins.py +165 -0
  242. data/tools/logilab/logilab/astng/node_classes.py +848 -0
  243. data/tools/logilab/logilab/astng/nodes.py +85 -0
  244. data/tools/logilab/logilab/astng/nodes_as_string.py +389 -0
  245. data/tools/logilab/logilab/astng/patchcomptransformer.py +159 -0
  246. data/tools/logilab/logilab/astng/protocols.py +333 -0
  247. data/tools/logilab/logilab/astng/raw_building.py +212 -0
  248. data/tools/logilab/logilab/astng/rebuilder.py +307 -0
  249. data/tools/logilab/logilab/astng/scoped_nodes.py +951 -0
  250. data/tools/logilab/logilab/astng/test/__init__.py +19 -0
  251. data/tools/logilab/logilab/astng/test/data/MyPyPa-0.1.0-py2.5.egg +0 -0
  252. data/tools/logilab/logilab/astng/test/data/MyPyPa-0.1.0-py2.5.zip +0 -0
  253. data/tools/logilab/logilab/astng/test/data/SSL1/Connection1.py +33 -0
  254. data/tools/logilab/logilab/astng/test/data/SSL1/__init__.py +20 -0
  255. data/tools/logilab/logilab/astng/test/data/__init__.py +20 -0
  256. data/tools/logilab/logilab/astng/test/data/all.py +29 -0
  257. data/tools/logilab/logilab/astng/test/data/appl/__init__.py +23 -0
  258. data/tools/logilab/logilab/astng/test/data/appl/myConnection.py +30 -0
  259. data/tools/logilab/logilab/astng/test/data/format.py +34 -0
  260. data/tools/logilab/logilab/astng/test/data/module.py +90 -0
  261. data/tools/logilab/logilab/astng/test/data/module2.py +112 -0
  262. data/tools/logilab/logilab/astng/test/data/noendingnewline.py +57 -0
  263. data/tools/logilab/logilab/astng/test/data/nonregr.py +76 -0
  264. data/tools/logilab/logilab/astng/test/data/notall.py +28 -0
  265. data/tools/logilab/logilab/astng/test/data2/__init__.py +20 -0
  266. data/tools/logilab/logilab/astng/test/data2/clientmodule_test.py +51 -0
  267. data/tools/logilab/logilab/astng/test/data2/suppliermodule_test.py +32 -0
  268. data/tools/logilab/logilab/astng/test/regrtest.py +135 -0
  269. data/tools/logilab/logilab/astng/test/regrtest_data/absimport.py +22 -0
  270. data/tools/logilab/logilab/astng/test/regrtest_data/descriptor_crash.py +31 -0
  271. data/tools/logilab/logilab/astng/test/regrtest_data/import_package_subpackage_module.py +68 -0
  272. data/tools/logilab/logilab/astng/test/regrtest_data/package/__init__.py +24 -0
  273. data/tools/logilab/logilab/astng/test/regrtest_data/package/subpackage/__init__.py +20 -0
  274. data/tools/logilab/logilab/astng/test/regrtest_data/package/subpackage/module.py +20 -0
  275. data/tools/logilab/logilab/astng/test/unittest_builder.py +684 -0
  276. data/tools/logilab/logilab/astng/test/unittest_inference.py +1112 -0
  277. data/tools/logilab/logilab/astng/test/unittest_inspector.py +105 -0
  278. data/tools/logilab/logilab/astng/test/unittest_lookup.py +302 -0
  279. data/tools/logilab/logilab/astng/test/unittest_manager.py +98 -0
  280. data/tools/logilab/logilab/astng/test/unittest_nodes.py +302 -0
  281. data/tools/logilab/logilab/astng/test/unittest_scoped_nodes.py +501 -0
  282. data/tools/logilab/logilab/astng/test/unittest_utils.py +104 -0
  283. data/tools/logilab/logilab/astng/utils.py +342 -0
  284. data/tools/logilab/logilab/common/__init__.py +140 -0
  285. data/tools/logilab/logilab/common/__pkginfo__.py +43 -0
  286. data/tools/logilab/logilab/common/adbh.py +35 -0
  287. data/tools/logilab/logilab/common/cache.py +114 -0
  288. data/tools/logilab/logilab/common/changelog.py +234 -0
  289. data/tools/logilab/logilab/common/clcommands.py +181 -0
  290. data/tools/logilab/logilab/common/cli.py +212 -0
  291. data/tools/logilab/logilab/common/compat.py +328 -0
  292. data/tools/logilab/logilab/common/configuration.py +1087 -0
  293. data/tools/logilab/logilab/common/contexts.py +58 -0
  294. data/tools/logilab/logilab/common/corbautils.py +117 -0
  295. data/tools/logilab/logilab/common/daemon.py +171 -0
  296. data/tools/logilab/logilab/common/date.py +279 -0
  297. data/tools/logilab/logilab/common/db.py +49 -0
  298. data/tools/logilab/logilab/common/dbf.py +229 -0
  299. data/tools/logilab/logilab/common/debugger.py +208 -0
  300. data/tools/logilab/logilab/common/decorators.py +190 -0
  301. data/tools/logilab/logilab/common/deprecation.py +118 -0
  302. data/tools/logilab/logilab/common/fileutils.py +409 -0
  303. data/tools/logilab/logilab/common/graph.py +259 -0
  304. data/tools/logilab/logilab/common/html.py +142 -0
  305. data/tools/logilab/logilab/common/interface.py +76 -0
  306. data/tools/logilab/logilab/common/logging_ext.py +166 -0
  307. data/tools/logilab/logilab/common/modutils.py +670 -0
  308. data/tools/logilab/logilab/common/optik_ext.py +383 -0
  309. data/tools/logilab/logilab/common/optparser.py +92 -0
  310. data/tools/logilab/logilab/common/pdf_ext.py +111 -0
  311. data/tools/logilab/logilab/common/proc.py +276 -0
  312. data/tools/logilab/logilab/common/pyro_ext.py +146 -0
  313. data/tools/logilab/logilab/common/pytest.py +754 -0
  314. data/tools/logilab/logilab/common/shellutils.py +383 -0
  315. data/tools/logilab/logilab/common/sphinx_ext.py +87 -0
  316. data/tools/logilab/logilab/common/sphinxutils.py +122 -0
  317. data/tools/logilab/logilab/common/sqlgen.py +31 -0
  318. data/tools/logilab/logilab/common/table.py +930 -0
  319. data/tools/logilab/logilab/common/tasksqueue.py +97 -0
  320. data/tools/logilab/logilab/common/test/__init__.py +1 -0
  321. data/tools/logilab/logilab/common/test/data/ChangeLog +184 -0
  322. data/tools/logilab/logilab/common/test/data/MyPyPa-0.1.0-py2.5.egg +0 -0
  323. data/tools/logilab/logilab/common/test/data/__init__.py +1 -0
  324. data/tools/logilab/logilab/common/test/data/content_differ_dir/NOTHING +0 -0
  325. data/tools/logilab/logilab/common/test/data/content_differ_dir/README +1 -0
  326. data/tools/logilab/logilab/common/test/data/content_differ_dir/subdir/coin +1 -0
  327. data/tools/logilab/logilab/common/test/data/content_differ_dir/subdir/toto.txt +53 -0
  328. data/tools/logilab/logilab/common/test/data/file_differ_dir/NOTHING +0 -0
  329. data/tools/logilab/logilab/common/test/data/file_differ_dir/README +1 -0
  330. data/tools/logilab/logilab/common/test/data/file_differ_dir/subdir/toto.txt +53 -0
  331. data/tools/logilab/logilab/common/test/data/file_differ_dir/subdirtwo/Hello +0 -0
  332. data/tools/logilab/logilab/common/test/data/find_test/__init__.py +0 -0
  333. data/tools/logilab/logilab/common/test/data/find_test/foo.txt +0 -0
  334. data/tools/logilab/logilab/common/test/data/find_test/module.py +0 -0
  335. data/tools/logilab/logilab/common/test/data/find_test/module2.py +0 -0
  336. data/tools/logilab/logilab/common/test/data/find_test/newlines.txt +0 -0
  337. data/tools/logilab/logilab/common/test/data/find_test/noendingnewline.py +0 -0
  338. data/tools/logilab/logilab/common/test/data/find_test/nonregr.py +0 -0
  339. data/tools/logilab/logilab/common/test/data/find_test/normal_file.txt +0 -0
  340. data/tools/logilab/logilab/common/test/data/find_test/spam.txt +0 -0
  341. data/tools/logilab/logilab/common/test/data/find_test/sub/doc.txt +0 -0
  342. data/tools/logilab/logilab/common/test/data/find_test/sub/momo.py +0 -0
  343. data/tools/logilab/logilab/common/test/data/find_test/test.ini +0 -0
  344. data/tools/logilab/logilab/common/test/data/find_test/test1.msg +0 -0
  345. data/tools/logilab/logilab/common/test/data/find_test/test2.msg +0 -0
  346. data/tools/logilab/logilab/common/test/data/find_test/write_protected_file.txt +0 -0
  347. data/tools/logilab/logilab/common/test/data/foo.txt +9 -0
  348. data/tools/logilab/logilab/common/test/data/module.py +88 -0
  349. data/tools/logilab/logilab/common/test/data/module2.py +77 -0
  350. data/tools/logilab/logilab/common/test/data/newlines.txt +3 -0
  351. data/tools/logilab/logilab/common/test/data/noendingnewline.py +36 -0
  352. data/tools/logilab/logilab/common/test/data/nonregr.py +14 -0
  353. data/tools/logilab/logilab/common/test/data/normal_file.txt +0 -0
  354. data/tools/logilab/logilab/common/test/data/reference_dir/NOTHING +0 -0
  355. data/tools/logilab/logilab/common/test/data/reference_dir/README +1 -0
  356. data/tools/logilab/logilab/common/test/data/reference_dir/subdir/coin +1 -0
  357. data/tools/logilab/logilab/common/test/data/reference_dir/subdir/toto.txt +53 -0
  358. data/tools/logilab/logilab/common/test/data/same_dir/NOTHING +0 -0
  359. data/tools/logilab/logilab/common/test/data/same_dir/README +1 -0
  360. data/tools/logilab/logilab/common/test/data/same_dir/subdir/coin +1 -0
  361. data/tools/logilab/logilab/common/test/data/same_dir/subdir/toto.txt +53 -0
  362. data/tools/logilab/logilab/common/test/data/spam.txt +9 -0
  363. data/tools/logilab/logilab/common/test/data/sub/doc.txt +1 -0
  364. data/tools/logilab/logilab/common/test/data/sub/momo.py +1 -0
  365. data/tools/logilab/logilab/common/test/data/subdir_differ_dir/NOTHING +0 -0
  366. data/tools/logilab/logilab/common/test/data/subdir_differ_dir/README +1 -0
  367. data/tools/logilab/logilab/common/test/data/subdir_differ_dir/subdir/coin +1 -0
  368. data/tools/logilab/logilab/common/test/data/subdir_differ_dir/subdir/toto.txt +53 -0
  369. data/tools/logilab/logilab/common/test/data/test.ini +20 -0
  370. data/tools/logilab/logilab/common/test/data/test1.msg +30 -0
  371. data/tools/logilab/logilab/common/test/data/test2.msg +42 -0
  372. data/tools/logilab/logilab/common/test/data/write_protected_file.txt +0 -0
  373. data/tools/logilab/logilab/common/test/foomod.py +17 -0
  374. data/tools/logilab/logilab/common/test/unittest_cache.py +129 -0
  375. data/tools/logilab/logilab/common/test/unittest_changelog.py +37 -0
  376. data/tools/logilab/logilab/common/test/unittest_compat.py +239 -0
  377. data/tools/logilab/logilab/common/test/unittest_configuration.py +348 -0
  378. data/tools/logilab/logilab/common/test/unittest_date.py +154 -0
  379. data/tools/logilab/logilab/common/test/unittest_decorators.py +62 -0
  380. data/tools/logilab/logilab/common/test/unittest_deprecation.py +76 -0
  381. data/tools/logilab/logilab/common/test/unittest_fileutils.py +133 -0
  382. data/tools/logilab/logilab/common/test/unittest_graph.py +50 -0
  383. data/tools/logilab/logilab/common/test/unittest_html.py +76 -0
  384. data/tools/logilab/logilab/common/test/unittest_interface.py +87 -0
  385. data/tools/logilab/logilab/common/test/unittest_modutils.py +244 -0
  386. data/tools/logilab/logilab/common/test/unittest_pytest.py +50 -0
  387. data/tools/logilab/logilab/common/test/unittest_shellutils.py +248 -0
  388. data/tools/logilab/logilab/common/test/unittest_table.py +448 -0
  389. data/tools/logilab/logilab/common/test/unittest_taskqueue.py +71 -0
  390. data/tools/logilab/logilab/common/test/unittest_testlib.py +956 -0
  391. data/tools/logilab/logilab/common/test/unittest_textutils.py +247 -0
  392. data/tools/logilab/logilab/common/test/unittest_tree.py +248 -0
  393. data/tools/logilab/logilab/common/test/unittest_umessage.py +55 -0
  394. data/tools/logilab/logilab/common/test/unittest_ureports_html.py +64 -0
  395. data/tools/logilab/logilab/common/test/unittest_ureports_text.py +105 -0
  396. data/tools/logilab/logilab/common/test/unittest_xmlutils.py +75 -0
  397. data/tools/logilab/logilab/common/test/utils.py +87 -0
  398. data/tools/logilab/logilab/common/testlib.py +1927 -0
  399. data/tools/logilab/logilab/common/textutils.py +476 -0
  400. data/tools/logilab/logilab/common/tree.py +372 -0
  401. data/tools/logilab/logilab/common/umessage.py +161 -0
  402. data/tools/logilab/logilab/common/ureports/__init__.py +174 -0
  403. data/tools/logilab/logilab/common/ureports/docbook_writer.py +139 -0
  404. data/tools/logilab/logilab/common/ureports/html_writer.py +131 -0
  405. data/tools/logilab/logilab/common/ureports/nodes.py +201 -0
  406. data/tools/logilab/logilab/common/ureports/text_writer.py +140 -0
  407. data/tools/logilab/logilab/common/vcgutils.py +216 -0
  408. data/tools/logilab/logilab/common/visitor.py +107 -0
  409. data/tools/logilab/logilab/common/xmlrpcutils.py +136 -0
  410. data/tools/logilab/logilab/common/xmlutils.py +61 -0
  411. data/tools/pychecker/COPYRIGHT +31 -0
  412. data/tools/pychecker/ChangeLog +349 -0
  413. data/tools/pychecker/CodeChecks.py +1969 -0
  414. data/tools/pychecker/CodeChecks.pyc +0 -0
  415. data/tools/pychecker/CodeChecks.pyo +0 -0
  416. data/tools/pychecker/Config.py +475 -0
  417. data/tools/pychecker/Config.pyc +0 -0
  418. data/tools/pychecker/Config.pyo +0 -0
  419. data/tools/pychecker/KNOWN_BUGS +100 -0
  420. data/tools/pychecker/MAINTAINERS +81 -0
  421. data/tools/pychecker/NEWS +406 -0
  422. data/tools/pychecker/OP.py +131 -0
  423. data/tools/pychecker/OP.pyc +0 -0
  424. data/tools/pychecker/OP.pyo +0 -0
  425. data/tools/pychecker/OptionTypes.py +117 -0
  426. data/tools/pychecker/OptionTypes.pyc +0 -0
  427. data/tools/pychecker/OptionTypes.pyo +0 -0
  428. data/tools/pychecker/README +152 -0
  429. data/tools/pychecker/Stack.py +115 -0
  430. data/tools/pychecker/Stack.pyc +0 -0
  431. data/tools/pychecker/Stack.pyo +0 -0
  432. data/tools/pychecker/TODO +101 -0
  433. data/tools/pychecker/VERSION +1 -0
  434. data/tools/pychecker/Warning.py +50 -0
  435. data/tools/pychecker/Warning.pyc +0 -0
  436. data/tools/pychecker/Warning.pyo +0 -0
  437. data/tools/pychecker/__init__.py +17 -0
  438. data/tools/pychecker/__init__.pyc +0 -0
  439. data/tools/pychecker/__init__.pyo +0 -0
  440. data/tools/pychecker/checker.py +961 -0
  441. data/tools/pychecker/checker.pyc +0 -0
  442. data/tools/pychecker/checker.pyo +0 -0
  443. data/tools/pychecker/function.py +159 -0
  444. data/tools/pychecker/function.pyc +0 -0
  445. data/tools/pychecker/function.pyo +0 -0
  446. data/tools/pychecker/msgs.py +175 -0
  447. data/tools/pychecker/msgs.pyc +0 -0
  448. data/tools/pychecker/msgs.pyo +0 -0
  449. data/tools/pychecker/options.py +275 -0
  450. data/tools/pychecker/options.pyc +0 -0
  451. data/tools/pychecker/options.pyo +0 -0
  452. data/tools/pychecker/pcmodules.py +19 -0
  453. data/tools/pychecker/pcmodules.pyc +0 -0
  454. data/tools/pychecker/pcmodules.pyo +0 -0
  455. data/tools/pychecker/printer.py +47 -0
  456. data/tools/pychecker/printer.pyc +0 -0
  457. data/tools/pychecker/printer.pyo +0 -0
  458. data/tools/pychecker/python.py +427 -0
  459. data/tools/pychecker/python.pyc +0 -0
  460. data/tools/pychecker/python.pyo +0 -0
  461. data/tools/pychecker/utils.py +102 -0
  462. data/tools/pychecker/utils.pyc +0 -0
  463. data/tools/pychecker/utils.pyo +0 -0
  464. data/tools/pychecker/warn.py +778 -0
  465. data/tools/pychecker/warn.pyc +0 -0
  466. data/tools/pychecker/warn.pyo +0 -0
  467. data/tools/pylint2/pylint/__init__.py +16 -0
  468. data/tools/pylint2/pylint/__pkginfo__.py +67 -0
  469. data/tools/pylint2/pylint/checkers/__init__.py +155 -0
  470. data/tools/pylint2/pylint/checkers/base.py +749 -0
  471. data/tools/pylint2/pylint/checkers/classes.py +527 -0
  472. data/tools/pylint2/pylint/checkers/design_analysis.py +344 -0
  473. data/tools/pylint2/pylint/checkers/exceptions.py +183 -0
  474. data/tools/pylint2/pylint/checkers/format.py +367 -0
  475. data/tools/pylint2/pylint/checkers/imports.py +379 -0
  476. data/tools/pylint2/pylint/checkers/logging.py +98 -0
  477. data/tools/pylint2/pylint/checkers/misc.py +128 -0
  478. data/tools/pylint2/pylint/checkers/newstyle.py +107 -0
  479. data/tools/pylint2/pylint/checkers/raw_metrics.py +125 -0
  480. data/tools/pylint2/pylint/checkers/similar.py +333 -0
  481. data/tools/pylint2/pylint/checkers/string_format.py +239 -0
  482. data/tools/pylint2/pylint/checkers/typecheck.py +364 -0
  483. data/tools/pylint2/pylint/checkers/utils.py +208 -0
  484. data/tools/pylint2/pylint/checkers/variables.py +498 -0
  485. data/tools/pylint2/pylint/config.py +149 -0
  486. data/tools/pylint2/pylint/epylint.py +149 -0
  487. data/tools/pylint2/pylint/gui.py +433 -0
  488. data/tools/pylint2/pylint/interfaces.py +98 -0
  489. data/tools/pylint2/pylint/lint.py +914 -0
  490. data/tools/pylint2/pylint/pyreverse/__init__.py +5 -0
  491. data/tools/pylint2/pylint/pyreverse/diadefslib.py +229 -0
  492. data/tools/pylint2/pylint/pyreverse/diagrams.py +247 -0
  493. data/tools/pylint2/pylint/pyreverse/main.py +123 -0
  494. data/tools/pylint2/pylint/pyreverse/utils.py +131 -0
  495. data/tools/pylint2/pylint/pyreverse/writer.py +196 -0
  496. data/tools/pylint2/pylint/reporters/__init__.py +67 -0
  497. data/tools/pylint2/pylint/reporters/guireporter.py +36 -0
  498. data/tools/pylint2/pylint/reporters/html.py +69 -0
  499. data/tools/pylint2/pylint/reporters/text.py +156 -0
  500. data/tools/pylint2/pylint/utils.py +518 -0
  501. data/tools/pylint2/pylint.py +16 -0
  502. data/tools/test/suite.py +35 -0
  503. metadata +566 -0
@@ -0,0 +1,754 @@
1
+ # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
2
+ # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
3
+ #
4
+ # This file is part of logilab-common.
5
+ #
6
+ # logilab-common is free software: you can redistribute it and/or modify it under
7
+ # the terms of the GNU Lesser General Public License as published by the Free
8
+ # Software Foundation, either version 2.1 of the License, or (at your option) any
9
+ # later version.
10
+ #
11
+ # logilab-common is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14
+ # details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public License along
17
+ # with logilab-common. If not, see <http://www.gnu.org/licenses/>.
18
+ """pytest is a tool that eases test running and debugging.
19
+
20
+ To be able to use pytest, you should either write tests using
21
+ the logilab.common.testlib's framework or the unittest module of the
22
+ Python's standard library.
23
+
24
+ You can customize pytest's behaviour by defining a ``pytestconf.py`` file
25
+ somewhere in your test directory. In this file, you can add options or
26
+ change the way tests are run.
27
+
28
+ To add command line options, you must define a ``update_parser`` function in
29
+ your ``pytestconf.py`` file. The function must accept a single parameter
30
+ that will be the OptionParser's instance to customize.
31
+
32
+ If you wish to customize the tester, you'll have to define a class named
33
+ ``CustomPyTester``. This class should extend the default `PyTester` class
34
+ defined in the pytest module. Take a look at the `PyTester` and `DjangoTester`
35
+ classes for more information about what can be done.
36
+
37
+ For instance, if you wish to add a custom -l option to specify a loglevel, you
38
+ could define the following ``pytestconf.py`` file ::
39
+
40
+ import logging
41
+ from logilab.common.pytest import PyTester
42
+
43
+ def update_parser(parser):
44
+ parser.add_option('-l', '--loglevel', dest='loglevel', action='store',
45
+ choices=('debug', 'info', 'warning', 'error', 'critical'),
46
+ default='critical', help="the default log level possible choices are "
47
+ "('debug', 'info', 'warning', 'error', 'critical')")
48
+ return parser
49
+
50
+
51
+ class CustomPyTester(PyTester):
52
+ def __init__(self, cvg, options):
53
+ super(CustomPyTester, self).__init__(cvg, options)
54
+ loglevel = options.loglevel.upper()
55
+ logger = logging.getLogger('erudi')
56
+ logger.setLevel(logging.getLevelName(loglevel))
57
+
58
+
59
+ In your TestCase class you can then get the value of a specific option with
60
+ the ``optval`` method::
61
+
62
+ class MyTestCase(TestCase):
63
+ def test_foo(self):
64
+ loglevel = self.optval('loglevel')
65
+ # ...
66
+
67
+
68
+ You can also tag your tag your test for fine filtering
69
+
70
+ With those tag::
71
+
72
+ from logilab.common.testlib import tag, TestCase
73
+
74
+ class Exemple(TestCase):
75
+
76
+ @tag('rouge', 'carre')
77
+ def toto(self):
78
+ pass
79
+
80
+ @tag('carre', 'vert')
81
+ def tata(self):
82
+ pass
83
+
84
+ @tag('rouge')
85
+ def titi(test):
86
+ pass
87
+
88
+ you can filter the function with a simple python expression
89
+
90
+ * ``toto`` and ``titi`` match ``rouge``
91
+
92
+ * ``toto``, ``tata`` and ``titi``, match ``rouge or carre``
93
+
94
+ * ``tata`` and ``titi`` match``rouge ^ carre``
95
+
96
+ * ``titi`` match ``rouge and not carre``
97
+ """
98
+ __docformat__ = "restructuredtext en"
99
+
100
+ PYTEST_DOC = """%prog [OPTIONS] [testfile [testpattern]]
101
+
102
+ examples:
103
+
104
+ pytest path/to/mytests.py
105
+ pytest path/to/mytests.py TheseTests
106
+ pytest path/to/mytests.py TheseTests.test_thisone
107
+ pytest path/to/mytests.py -m '(not long and database) or regr'
108
+
109
+ pytest one (will run both test_thisone and test_thatone)
110
+ pytest path/to/mytests.py -s not (will skip test_notthisone)
111
+
112
+ pytest --coverage test_foo.py
113
+ (only if logilab.devtools is available)
114
+ """
115
+
116
+ import os, sys, re
117
+ import os.path as osp
118
+ from time import time, clock
119
+ import warnings
120
+
121
+ from logilab.common.fileutils import abspath_listdir
122
+ from logilab.common import testlib
123
+ import doctest
124
+ import unittest
125
+
126
+
127
+ import imp
128
+
129
+ import __builtin__
130
+
131
+
132
+ try:
133
+ import django
134
+ from logilab.common.modutils import modpath_from_file, load_module_from_modpath
135
+ DJANGO_FOUND = True
136
+ except ImportError:
137
+ DJANGO_FOUND = False
138
+
139
+ CONF_FILE = 'pytestconf.py'
140
+
141
+ ## coverage hacks, do not read this, do not read this, do not read this
142
+
143
+ # hey, but this is an aspect, right ?!!!
144
+ class TraceController(object):
145
+ nesting = 0
146
+
147
+ def pause_tracing(cls):
148
+ if not cls.nesting:
149
+ cls.tracefunc = staticmethod(getattr(sys, '__settrace__', sys.settrace))
150
+ cls.oldtracer = getattr(sys, '__tracer__', None)
151
+ sys.__notrace__ = True
152
+ cls.tracefunc(None)
153
+ cls.nesting += 1
154
+ pause_tracing = classmethod(pause_tracing)
155
+
156
+ def resume_tracing(cls):
157
+ cls.nesting -= 1
158
+ assert cls.nesting >= 0
159
+ if not cls.nesting:
160
+ cls.tracefunc(cls.oldtracer)
161
+ delattr(sys, '__notrace__')
162
+ resume_tracing = classmethod(resume_tracing)
163
+
164
+
165
+ pause_tracing = TraceController.pause_tracing
166
+ resume_tracing = TraceController.resume_tracing
167
+
168
+
169
+ def nocoverage(func):
170
+ if hasattr(func, 'uncovered'):
171
+ return func
172
+ func.uncovered = True
173
+ def not_covered(*args, **kwargs):
174
+ pause_tracing()
175
+ try:
176
+ return func(*args, **kwargs)
177
+ finally:
178
+ resume_tracing()
179
+ not_covered.uncovered = True
180
+ return not_covered
181
+
182
+
183
+ ## end of coverage hacks
184
+
185
+
186
+ # monkeypatch unittest and doctest (ouch !)
187
+ unittest.TestCase = testlib.TestCase
188
+ unittest.main = testlib.unittest_main
189
+ unittest._TextTestResult = testlib.SkipAwareTestResult
190
+ unittest.TextTestRunner = testlib.SkipAwareTextTestRunner
191
+ unittest.TestLoader = testlib.NonStrictTestLoader
192
+ unittest.TestProgram = testlib.SkipAwareTestProgram
193
+ if sys.version_info >= (2, 4):
194
+ doctest.DocTestCase.__bases__ = (testlib.TestCase,)
195
+ else:
196
+ unittest.FunctionTestCase.__bases__ = (testlib.TestCase,)
197
+
198
+
199
+
200
+ TESTFILE_RE = re.compile("^((unit)?test.*|smoketest)\.py$")
201
+ def this_is_a_testfile(filename):
202
+ """returns True if `filename` seems to be a test file"""
203
+ return TESTFILE_RE.match(osp.basename(filename))
204
+
205
+ TESTDIR_RE = re.compile("^(unit)?tests?$")
206
+ def this_is_a_testdir(dirpath):
207
+ """returns True if `filename` seems to be a test directory"""
208
+ return TESTDIR_RE.match(osp.basename(dirpath))
209
+
210
+
211
+ def load_pytest_conf(path, parser):
212
+ """loads a ``pytestconf.py`` file and update default parser
213
+ and / or tester.
214
+ """
215
+ namespace = {}
216
+ execfile(path, namespace)
217
+ if 'update_parser' in namespace:
218
+ namespace['update_parser'](parser)
219
+ return namespace.get('CustomPyTester', PyTester)
220
+
221
+
222
+ def project_root(parser, projdir=os.getcwd()):
223
+ """try to find project's root and add it to sys.path"""
224
+ curdir = osp.abspath(projdir)
225
+ previousdir = curdir
226
+ testercls = PyTester
227
+ conf_file_path = osp.join(curdir, CONF_FILE)
228
+ if osp.isfile(conf_file_path):
229
+ testercls = load_pytest_conf(conf_file_path, parser)
230
+ while this_is_a_testdir(curdir) or \
231
+ osp.isfile(osp.join(curdir, '__init__.py')):
232
+ newdir = osp.normpath(osp.join(curdir, os.pardir))
233
+ if newdir == curdir:
234
+ break
235
+ previousdir = curdir
236
+ curdir = newdir
237
+ conf_file_path = osp.join(curdir, CONF_FILE)
238
+ if osp.isfile(conf_file_path):
239
+ testercls = load_pytest_conf(conf_file_path, parser)
240
+ return previousdir, testercls
241
+
242
+
243
+ class GlobalTestReport(object):
244
+ """this class holds global test statistics"""
245
+ def __init__(self):
246
+ self.ran = 0
247
+ self.skipped = 0
248
+ self.failures = 0
249
+ self.errors = 0
250
+ self.ttime = 0
251
+ self.ctime = 0
252
+ self.modulescount = 0
253
+ self.errmodules = []
254
+
255
+ def feed(self, filename, testresult, ttime, ctime):
256
+ """integrates new test information into internal statistics"""
257
+ ran = testresult.testsRun
258
+ self.ran += ran
259
+ self.skipped += len(getattr(testresult, 'skipped', ()))
260
+ self.failures += len(testresult.failures)
261
+ self.errors += len(testresult.errors)
262
+ self.ttime += ttime
263
+ self.ctime += ctime
264
+ self.modulescount += 1
265
+ if not testresult.wasSuccessful():
266
+ problems = len(testresult.failures) + len(testresult.errors)
267
+ self.errmodules.append((filename[:-3], problems, ran))
268
+
269
+
270
+ def failed_to_test_module(self, filename):
271
+ """called when the test module could not be imported by unittest
272
+ """
273
+ self.errors += 1
274
+ self.modulescount += 1
275
+ self.ran += 1
276
+ self.errmodules.append((filename[:-3], 1, 1))
277
+
278
+ def skip_module(self, filename):
279
+ self.modulescount += 1
280
+ self.ran += 1
281
+ self.errmodules.append((filename[:-3], 0, 0))
282
+
283
+ def __str__(self):
284
+ """this is just presentation stuff"""
285
+ line1 = ['Ran %s test cases in %.2fs (%.2fs CPU)'
286
+ % (self.ran, self.ttime, self.ctime)]
287
+ if self.errors:
288
+ line1.append('%s errors' % self.errors)
289
+ if self.failures:
290
+ line1.append('%s failures' % self.failures)
291
+ if self.skipped:
292
+ line1.append('%s skipped' % self.skipped)
293
+ modulesok = self.modulescount - len(self.errmodules)
294
+ if self.errors or self.failures:
295
+ line2 = '%s modules OK (%s failed)' % (modulesok,
296
+ len(self.errmodules))
297
+ descr = ', '.join(['%s [%s/%s]' % info for info in self.errmodules])
298
+ line3 = '\nfailures: %s' % descr
299
+ elif modulesok:
300
+ line2 = 'All %s modules OK' % modulesok
301
+ line3 = ''
302
+ else:
303
+ return ''
304
+ return '%s\n%s%s' % (', '.join(line1), line2, line3)
305
+
306
+
307
+
308
+ def remove_local_modules_from_sys(testdir):
309
+ """remove all modules from cache that come from `testdir`
310
+
311
+ This is used to avoid strange side-effects when using the
312
+ testall() mode of pytest.
313
+ For instance, if we run pytest on this tree::
314
+
315
+ A/test/test_utils.py
316
+ B/test/test_utils.py
317
+
318
+ we **have** to clean sys.modules to make sure the correct test_utils
319
+ module is ran in B
320
+ """
321
+ for modname, mod in sys.modules.items():
322
+ if mod is None:
323
+ continue
324
+ if not hasattr(mod, '__file__'):
325
+ # this is the case of some built-in modules like sys, imp, marshal
326
+ continue
327
+ modfile = mod.__file__
328
+ # if modfile is not an absolute path, it was probably loaded locally
329
+ # during the tests
330
+ if not osp.isabs(modfile) or modfile.startswith(testdir):
331
+ del sys.modules[modname]
332
+
333
+
334
+
335
+ class PyTester(object):
336
+ """encapsulates testrun logic"""
337
+
338
+ def __init__(self, cvg, options):
339
+ self.report = GlobalTestReport()
340
+ self.cvg = cvg
341
+ self.options = options
342
+ self.firstwrite = True
343
+ self._errcode = None
344
+
345
+ def show_report(self):
346
+ """prints the report and returns appropriate exitcode"""
347
+ # everything has been ran, print report
348
+ print "*" * 79
349
+ print self.report
350
+
351
+ def get_errcode(self):
352
+ # errcode set explicitly
353
+ if self._errcode is not None:
354
+ return self._errcode
355
+ return self.report.failures + self.report.errors
356
+
357
+ def set_errcode(self, errcode):
358
+ self._errcode = errcode
359
+ errcode = property(get_errcode, set_errcode)
360
+
361
+ def testall(self, exitfirst=False):
362
+ """walks through current working directory, finds something
363
+ which can be considered as a testdir and runs every test there
364
+ """
365
+ here = os.getcwd()
366
+ for dirname, dirs, _ in os.walk(here):
367
+ for skipped in ('CVS', '.svn', '.hg'):
368
+ if skipped in dirs:
369
+ dirs.remove(skipped)
370
+ basename = osp.basename(dirname)
371
+ if this_is_a_testdir(basename):
372
+ print "going into", dirname
373
+ # we found a testdir, let's explore it !
374
+ if not self.testonedir(dirname, exitfirst):
375
+ break
376
+ dirs[:] = []
377
+ if self.report.ran == 0:
378
+ print "no test dir found testing here:", here
379
+ # if no test was found during the visit, consider
380
+ # the local directory as a test directory even if
381
+ # it doesn't have a traditional test directory name
382
+ self.testonedir(here)
383
+
384
+ def testonedir(self, testdir, exitfirst=False):
385
+ """finds each testfile in the `testdir` and runs it
386
+
387
+ return true when all tests has been executed, false if exitfirst and
388
+ some test has failed.
389
+ """
390
+ for filename in abspath_listdir(testdir):
391
+ if this_is_a_testfile(filename):
392
+ if self.options.exitfirst and not self.options.restart:
393
+ # overwrite restart file
394
+ try:
395
+ restartfile = open(testlib.FILE_RESTART, "w")
396
+ restartfile.close()
397
+ except Exception, e:
398
+ print >> sys.__stderr__, "Error while overwriting \
399
+ succeeded test file :", osp.join(os.getcwd(),testlib.FILE_RESTART)
400
+ raise e
401
+ # run test and collect information
402
+ prog = self.testfile(filename, batchmode=True)
403
+ if exitfirst and (prog is None or not prog.result.wasSuccessful()):
404
+ return False
405
+ self.firstwrite = True
406
+ # clean local modules
407
+ remove_local_modules_from_sys(testdir)
408
+ return True
409
+
410
+ def testfile(self, filename, batchmode=False):
411
+ """runs every test in `filename`
412
+
413
+ :param filename: an absolute path pointing to a unittest file
414
+ """
415
+ here = os.getcwd()
416
+ dirname = osp.dirname(filename)
417
+ if dirname:
418
+ os.chdir(dirname)
419
+ # overwrite restart file if it has not been done already
420
+ if self.options.exitfirst and not self.options.restart and self.firstwrite:
421
+ try:
422
+ restartfile = open(testlib.FILE_RESTART, "w")
423
+ restartfile.close()
424
+ except Exception, e:
425
+ print >> sys.__stderr__, "Error while overwriting \
426
+ succeeded test file :", osp.join(os.getcwd(),testlib.FILE_RESTART)
427
+ raise e
428
+ modname = osp.basename(filename)[:-3]
429
+ try:
430
+ print >> sys.stderr, (' %s ' % osp.basename(filename)).center(70, '=')
431
+ except TypeError: # < py 2.4 bw compat
432
+ print >> sys.stderr, (' %s ' % osp.basename(filename)).center(70)
433
+ try:
434
+ tstart, cstart = time(), clock()
435
+ try:
436
+ testprog = testlib.unittest_main(modname, batchmode=batchmode, cvg=self.cvg,
437
+ options=self.options, outstream=sys.stderr)
438
+ except KeyboardInterrupt:
439
+ raise
440
+ except SystemExit, exc:
441
+ self.errcode = exc.code
442
+ raise
443
+ except testlib.TestSkipped:
444
+ print "Module skipped:", filename
445
+ self.report.skip_module(filename)
446
+ return None
447
+ except Exception:
448
+ self.report.failed_to_test_module(filename)
449
+ print >> sys.stderr, 'unhandled exception occurred while testing', modname
450
+ import traceback
451
+ traceback.print_exc(file=sys.stderr)
452
+ return None
453
+
454
+ tend, cend = time(), clock()
455
+ ttime, ctime = (tend - tstart), (cend - cstart)
456
+ self.report.feed(filename, testprog.result, ttime, ctime)
457
+ return testprog
458
+ finally:
459
+ if dirname:
460
+ os.chdir(here)
461
+
462
+
463
+
464
+ class DjangoTester(PyTester):
465
+
466
+ def load_django_settings(self, dirname):
467
+ """try to find project's setting and load it"""
468
+ curdir = osp.abspath(dirname)
469
+ previousdir = curdir
470
+ while not osp.isfile(osp.join(curdir, 'settings.py')) and \
471
+ osp.isfile(osp.join(curdir, '__init__.py')):
472
+ newdir = osp.normpath(osp.join(curdir, os.pardir))
473
+ if newdir == curdir:
474
+ raise AssertionError('could not find settings.py')
475
+ previousdir = curdir
476
+ curdir = newdir
477
+ # late django initialization
478
+ settings = load_module_from_modpath(modpath_from_file(osp.join(curdir, 'settings.py')))
479
+ from django.core.management import setup_environ
480
+ setup_environ(settings)
481
+ settings.DEBUG = False
482
+ self.settings = settings
483
+ # add settings dir to pythonpath since it's the project's root
484
+ if curdir not in sys.path:
485
+ sys.path.insert(1, curdir)
486
+
487
+ def before_testfile(self):
488
+ # Those imports must be done **after** setup_environ was called
489
+ from django.test.utils import setup_test_environment
490
+ from django.test.utils import create_test_db
491
+ setup_test_environment()
492
+ create_test_db(verbosity=0)
493
+ self.dbname = self.settings.TEST_DATABASE_NAME
494
+
495
+
496
+ def after_testfile(self):
497
+ # Those imports must be done **after** setup_environ was called
498
+ from django.test.utils import teardown_test_environment
499
+ from django.test.utils import destroy_test_db
500
+ teardown_test_environment()
501
+ print 'destroying', self.dbname
502
+ destroy_test_db(self.dbname, verbosity=0)
503
+
504
+
505
+ def testall(self, exitfirst=False):
506
+ """walks through current working directory, finds something
507
+ which can be considered as a testdir and runs every test there
508
+ """
509
+ for dirname, dirs, _ in os.walk(os.getcwd()):
510
+ for skipped in ('CVS', '.svn', '.hg'):
511
+ if skipped in dirs:
512
+ dirs.remove(skipped)
513
+ if 'tests.py' in files:
514
+ if not self.testonedir(dirname, exitfirst):
515
+ break
516
+ dirs[:] = []
517
+ else:
518
+ basename = osp.basename(dirname)
519
+ if basename in ('test', 'tests'):
520
+ print "going into", dirname
521
+ # we found a testdir, let's explore it !
522
+ if not self.testonedir(dirname, exitfirst):
523
+ break
524
+ dirs[:] = []
525
+
526
+
527
+ def testonedir(self, testdir, exitfirst=False):
528
+ """finds each testfile in the `testdir` and runs it
529
+
530
+ return true when all tests has been executed, false if exitfirst and
531
+ some test has failed.
532
+ """
533
+ # special django behaviour : if tests are splitted in several files,
534
+ # remove the main tests.py file and tests each test file separately
535
+ testfiles = [fpath for fpath in abspath_listdir(testdir)
536
+ if this_is_a_testfile(fpath)]
537
+ if len(testfiles) > 1:
538
+ try:
539
+ testfiles.remove(osp.join(testdir, 'tests.py'))
540
+ except ValueError:
541
+ pass
542
+ for filename in testfiles:
543
+ # run test and collect information
544
+ prog = self.testfile(filename, batchmode=True)
545
+ if exitfirst and (prog is None or not prog.result.wasSuccessful()):
546
+ return False
547
+ # clean local modules
548
+ remove_local_modules_from_sys(testdir)
549
+ return True
550
+
551
+
552
+ def testfile(self, filename, batchmode=False):
553
+ """runs every test in `filename`
554
+
555
+ :param filename: an absolute path pointing to a unittest file
556
+ """
557
+ here = os.getcwd()
558
+ dirname = osp.dirname(filename)
559
+ if dirname:
560
+ os.chdir(dirname)
561
+ self.load_django_settings(dirname)
562
+ modname = osp.basename(filename)[:-3]
563
+ print >>sys.stderr, (' %s ' % osp.basename(filename)).center(70, '=')
564
+ try:
565
+ try:
566
+ tstart, cstart = time(), clock()
567
+ self.before_testfile()
568
+ testprog = testlib.unittest_main(modname, batchmode=batchmode, cvg=self.cvg)
569
+ tend, cend = time(), clock()
570
+ ttime, ctime = (tend - tstart), (cend - cstart)
571
+ self.report.feed(filename, testprog.result, ttime, ctime)
572
+ return testprog
573
+ except SystemExit:
574
+ raise
575
+ except Exception, exc:
576
+ import traceback
577
+ traceback.print_exc()
578
+ self.report.failed_to_test_module(filename)
579
+ print 'unhandled exception occurred while testing', modname
580
+ print 'error: %s' % exc
581
+ return None
582
+ finally:
583
+ self.after_testfile()
584
+ if dirname:
585
+ os.chdir(here)
586
+
587
+
588
+ def make_parser():
589
+ """creates the OptionParser instance
590
+ """
591
+ from optparse import OptionParser
592
+ parser = OptionParser(usage=PYTEST_DOC)
593
+
594
+ parser.newargs = []
595
+ def rebuild_cmdline(option, opt, value, parser):
596
+ """carry the option to unittest_main"""
597
+ parser.newargs.append(opt)
598
+
599
+ def rebuild_and_store(option, opt, value, parser):
600
+ """carry the option to unittest_main and store
601
+ the value on current parser
602
+ """
603
+ parser.newargs.append(opt)
604
+ setattr(parser.values, option.dest, True)
605
+
606
+ def capture_and_rebuild(option, opt, value, parser):
607
+ warnings.simplefilter('ignore', DeprecationWarning)
608
+ rebuild_cmdline(option, opt, value, parser)
609
+
610
+ # pytest options
611
+ parser.add_option('-t', dest='testdir', default=None,
612
+ help="directory where the tests will be found")
613
+ parser.add_option('-d', dest='dbc', default=False,
614
+ action="store_true", help="enable design-by-contract")
615
+ # unittest_main options provided and passed through pytest
616
+ parser.add_option('-v', '--verbose', callback=rebuild_cmdline,
617
+ action="callback", help="Verbose output")
618
+ parser.add_option('-i', '--pdb', callback=rebuild_and_store,
619
+ dest="pdb", action="callback",
620
+ help="Enable test failure inspection (conflicts with --coverage)")
621
+ parser.add_option('-x', '--exitfirst', callback=rebuild_and_store,
622
+ dest="exitfirst", default=False,
623
+ action="callback", help="Exit on first failure "
624
+ "(only make sense when pytest run one test file)")
625
+ parser.add_option('-R', '--restart', callback=rebuild_and_store,
626
+ dest="restart", default=False,
627
+ action="callback",
628
+ help="Restart tests from where it failed (implies exitfirst) "
629
+ "(only make sense if tests previously ran with exitfirst only)")
630
+ parser.add_option('-c', '--capture', callback=capture_and_rebuild,
631
+ action="callback",
632
+ help="Captures and prints standard out/err only on errors "
633
+ "(only make sense when pytest run one test file)")
634
+ parser.add_option('--color', callback=rebuild_cmdline,
635
+ action="callback",
636
+ help="colorize tracebacks")
637
+ parser.add_option('-p', '--printonly',
638
+ # XXX: I wish I could use the callback action but it
639
+ # doesn't seem to be able to get the value
640
+ # associated to the option
641
+ action="store", dest="printonly", default=None,
642
+ help="Only prints lines matching specified pattern (implies capture) "
643
+ "(only make sense when pytest run one test file)")
644
+ parser.add_option('-s', '--skip',
645
+ # XXX: I wish I could use the callback action but it
646
+ # doesn't seem to be able to get the value
647
+ # associated to the option
648
+ action="store", dest="skipped", default=None,
649
+ help="test names matching this name will be skipped "
650
+ "to skip several patterns, use commas")
651
+ parser.add_option('-q', '--quiet', callback=rebuild_cmdline,
652
+ action="callback", help="Minimal output")
653
+ parser.add_option('-P', '--profile', default=None, dest='profile',
654
+ help="Profile execution and store data in the given file")
655
+ parser.add_option('-m', '--match', default=None, dest='tags_pattern',
656
+ help="only execute test whose tag match the current pattern")
657
+
658
+ try:
659
+ from logilab.devtools.lib.coverage import Coverage
660
+ parser.add_option('--coverage', dest="coverage", default=False,
661
+ action="store_true",
662
+ help="run tests with pycoverage (conflicts with --pdb)")
663
+ except ImportError:
664
+ pass
665
+
666
+ if DJANGO_FOUND:
667
+ parser.add_option('-J', '--django', dest='django', default=False,
668
+ action="store_true",
669
+ help='use pytest for django test cases')
670
+ return parser
671
+
672
+
673
+ def parseargs(parser):
674
+ """Parse the command line and return (options processed), (options to pass to
675
+ unittest_main()), (explicitfile or None).
676
+ """
677
+ # parse the command line
678
+ options, args = parser.parse_args()
679
+ if options.pdb and getattr(options, 'coverage', False):
680
+ parser.error("'pdb' and 'coverage' options are exclusive")
681
+ filenames = [arg for arg in args if arg.endswith('.py')]
682
+ if filenames:
683
+ if len(filenames) > 1:
684
+ parser.error("only one filename is acceptable")
685
+ explicitfile = filenames[0]
686
+ args.remove(explicitfile)
687
+ else:
688
+ explicitfile = None
689
+ # someone wants DBC
690
+ testlib.ENABLE_DBC = options.dbc
691
+ newargs = parser.newargs
692
+ if options.printonly:
693
+ newargs.extend(['--printonly', options.printonly])
694
+ if options.skipped:
695
+ newargs.extend(['--skip', options.skipped])
696
+ # restart implies exitfirst
697
+ if options.restart:
698
+ options.exitfirst = True
699
+ # append additional args to the new sys.argv and let unittest_main
700
+ # do the rest
701
+ newargs += args
702
+ return options, explicitfile
703
+
704
+
705
+
706
+ def run():
707
+ parser = make_parser()
708
+ rootdir, testercls = project_root(parser)
709
+ options, explicitfile = parseargs(parser)
710
+ # mock a new command line
711
+ sys.argv[1:] = parser.newargs
712
+ covermode = getattr(options, 'coverage', None)
713
+ cvg = None
714
+ if not '' in sys.path:
715
+ sys.path.insert(0, '')
716
+ if covermode:
717
+ # control_import_coverage(rootdir)
718
+ from logilab.devtools.lib.coverage import Coverage
719
+ cvg = Coverage([rootdir])
720
+ cvg.erase()
721
+ cvg.start()
722
+ if DJANGO_FOUND and options.django:
723
+ tester = DjangoTester(cvg, options)
724
+ else:
725
+ tester = testercls(cvg, options)
726
+ if explicitfile:
727
+ cmd, args = tester.testfile, (explicitfile,)
728
+ elif options.testdir:
729
+ cmd, args = tester.testonedir, (options.testdir, options.exitfirst)
730
+ else:
731
+ cmd, args = tester.testall, (options.exitfirst,)
732
+ try:
733
+ try:
734
+ if options.profile:
735
+ import hotshot
736
+ prof = hotshot.Profile(options.profile)
737
+ prof.runcall(cmd, *args)
738
+ prof.close()
739
+ print 'profile data saved in', options.profile
740
+ else:
741
+ cmd(*args)
742
+ except SystemExit:
743
+ raise
744
+ except:
745
+ import traceback
746
+ traceback.print_exc()
747
+ finally:
748
+ if covermode:
749
+ cvg.stop()
750
+ cvg.save()
751
+ tester.show_report()
752
+ if covermode:
753
+ print 'coverage information stored, use it with pycoverage -ra'
754
+ sys.exit(tester.errcode)