Skip to content

Commit 7b30e51

Browse files
committed
Mock req when converting wiki to HTML
Some parts of the conversion code tries to use permissions or other parts of the request, which aren’t always present (for example when we convert wiki text on the console)
1 parent 19d3b06 commit 7b30e51

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

code_comments/comment.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
from time import strftime, localtime
77
from code_comments import db
88
from trac.util import Markup
9+
from trac.web.href import Href
10+
from trac.test import EnvironmentStub, Mock, MockPerm
911

1012
try:
1113
import json
@@ -162,5 +164,6 @@ def default(self, o):
162164
return json.JSONEncoder.default(self, o)
163165

164166
def format_to_html(req, env, text):
167+
req = Mock(href=Href('/'), abs_href=Href('http://www.example.com/'), authname='anonymous', perm=MockPerm(), args={})
165168
context = Context.from_request(req)
166169
return trac.wiki.formatter.format_to_html(env, context, text)

0 commit comments

Comments
 (0)