summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Crute <mcrute@gmail.com>2010-07-26 19:01:29 -0400
committerMike Crute <mcrute@gmail.com>2010-07-26 19:01:29 -0400
commit3342871c734f8d9c8ca859a4be77f82e7083bdea (patch)
treef4a7dc2db5f4ec5a126d1ee6c3d91c65e2672891
parentfce5b0ec38fe4050d02c3903c2c17c5a83c8f4a7 (diff)
downloadnose-machineout-3342871c734f8d9c8ca859a4be77f82e7083bdea.tar.bz2
nose-machineout-3342871c734f8d9c8ca859a4be77f82e7083bdea.tar.xz
nose-machineout-3342871c734f8d9c8ca859a4be77f82e7083bdea.zip
Removing doctests support since I don't really like doctests.
-rw-r--r--machineout.py39
1 files changed, 3 insertions, 36 deletions
diff --git a/machineout.py b/machineout.py
index 3b47e68..fc62875 100644
--- a/machineout.py
+++ b/machineout.py
@@ -4,7 +4,6 @@ It is intended to be use to integrate nose with your IDE such as Vim.
4""" 4"""
5 5
6import re 6import re
7import os.path
8import traceback 7import traceback
9from nose.plugins import Plugin 8from nose.plugins import Plugin
10 9
@@ -12,14 +11,6 @@ from nose.plugins import Plugin
12__all__ = ['NoseMachineReadableOutput'] 11__all__ = ['NoseMachineReadableOutput']
13 12
14 13
15try:
16 import doctest
17 doctest_fname = re.sub('\.py.?$', '.py', doctest.__file__)
18 del doctest
19except ImportError:
20 doctest_fname = None
21
22
23class dummystream: 14class dummystream:
24 15
25 def write(self, *arg): 16 def write(self, *arg):
@@ -32,14 +23,6 @@ class dummystream:
32 pass 23 pass
33 24
34 25
35def is_doctest_traceback(fname):
36 return fname == doctest_fname
37
38
39class PluginError(Exception):
40 pass
41
42
43class NoseMachineReadableOutput(Plugin): 26class NoseMachineReadableOutput(Plugin):
44 """ 27 """
45 Output errors and failures in a machine-readable way. 28 Output errors and failures in a machine-readable way.
@@ -87,25 +70,9 @@ class NoseMachineReadableOutput(Plugin):
87 except IndexError: 70 except IndexError:
88 fname, lineno, funname, msg = fallback 71 fname, lineno, funname, msg = fallback
89 72
90 # explicit support for doctests is needed 73 lines = traceback.format_exception_only(exctype, value)
91 if is_doctest_traceback(fname): 74 lines = [line.strip('\n') for line in lines]
92 # doctest traceback includes pre-formatted error message 75 msg0 = lines[0]
93 # which we parse (in a very crude way).
94 n = value.args[0].rindex('-'*20)
95 formatted_msg = value.args[0][n+20+1:]
96 m = self.doctest_failure_re.match(formatted_msg)
97 if not m:
98 raise RuntimeError("Can't parse doctest output: %r" % value.args[0])
99 fname, lineno, funname, msg = m.groups()
100 if '.' in funname: # strip module package name, if any
101 funname = funname.split('.')[-1]
102 lineno = int(lineno)
103 lines = msg.split('\n')
104 msg0 = lines[0]
105 else:
106 lines = traceback.format_exception_only(exctype, value)
107 lines = [line.strip('\n') for line in lines]
108 msg0 = lines[0]
109 76
110 fname = self.format_testfname(fname) 77 fname = self.format_testfname(fname)
111 prefix = "%s:%d" % (fname, lineno) 78 prefix = "%s:%d" % (fname, lineno)