@@ -130,25 +130,23 @@ def run(self):
130
130
class _StringPrefixFixer (_OutputChecker ):
131
131
132
132
def check_output (self , want , got , optionflags ):
133
- if sys .version_info [0 ] >= 3 :
134
- # The docstrings are written with python 2.x in mind.
135
- # To make the doctests pass in python 3 we have to
136
- # strip the 'u' prefix from the expected results. The
137
- # actual results won't have that prefix.
138
- want = re .sub (_u_literal_re , r'\1\2' , want )
139
- # We also have to strip the 'b' prefix from the actual
140
- # results since python 2.x expected results won't have
141
- # that prefix.
142
- got = re .sub (_b_literal_re , r'\1\2' , got )
133
+ # The docstrings are written with python 2.x in mind.
134
+ # To make the doctests pass in python 3 we have to
135
+ # strip the 'u' prefix from the expected results. The
136
+ # actual results won't have that prefix.
137
+ want = re .sub (_u_literal_re , r'\1\2' , want )
138
+ # We also have to strip the 'b' prefix from the actual
139
+ # results since python 2.x expected results won't have
140
+ # that prefix.
141
+ got = re .sub (_b_literal_re , r'\1\2' , got )
143
142
return super (
144
143
_StringPrefixFixer , self ).check_output (
145
144
want , got , optionflags )
146
145
147
146
def output_difference (self , example , got , optionflags ):
148
- if sys .version_info [0 ] >= 3 :
149
- example .want = re .sub (
150
- _u_literal_re , r'\1\2' , example .want )
151
- got = re .sub (_b_literal_re , r'\1\2' , got )
147
+ example .want = re .sub (
148
+ _u_literal_re , r'\1\2' , example .want )
149
+ got = re .sub (_b_literal_re , r'\1\2' , got )
152
150
return super (
153
151
_StringPrefixFixer , self ).output_difference (
154
152
example , got , optionflags )
@@ -159,18 +157,28 @@ def output_difference(self, example, got, optionflags):
159
157
build_py .run (self )
160
158
161
159
if self .test :
162
- path = "doc/_build/doctest"
160
+ path = os .path .join (
161
+ os .path .abspath ('.' ), "doc" , "_build" , "doctest" )
163
162
mode = "doctest"
164
163
else :
165
- path = "doc/_build/%s" % version
164
+ path = os .path .join (
165
+ os .path .abspath ('.' ), "doc" , "_build" , version )
166
166
mode = "html"
167
167
168
168
try :
169
169
os .makedirs (path )
170
170
except :
171
171
pass
172
172
173
- status = sphinx .main (["-E" , "-b" , mode , "doc" , path ])
173
+ sphinx_args = ["-E" , "-b" , mode , "doc" , path ]
174
+
175
+ # sphinx.main calls sys.exit when sphinx.build_main exists.
176
+ # Call build_main directly so we can check status and print
177
+ # the full path to the built docs.
178
+ if hasattr (sphinx , 'build_main' ):
179
+ status = sphinx .build_main (sphinx_args )
180
+ else :
181
+ status = sphinx .main (sphinx_args )
174
182
175
183
if status :
176
184
raise RuntimeError ("documentation step '%s' failed" % (mode ,))
0 commit comments