Skip to content

Commit

Permalink
Merge pull request #295 from JohnBrodie/sphinxext-python3
Browse files Browse the repository at this point in the history
Import reload for Python 3
  • Loading branch information
almet committed Jul 7, 2015
2 parents eff8f6f + fdc94f9 commit 6647ac4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cornice/ext/sphinxext.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
import sys
import json
from importlib import import_module
try:
from importlib import reload
except ImportError:
pass

from cornice.util import to_list, is_string, PY3
from cornice.service import get_services, clear_services
Expand Down
14 changes: 13 additions & 1 deletion cornice/tests/ext/test_sphinxext.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
import mock

from cornice.tests.support import TestCase
from cornice.ext.sphinxext import rst2html
from cornice.ext.sphinxext import rst2html, ServiceDirective


class TestUtil(TestCase):
Expand All @@ -12,3 +14,13 @@ def test_rendering(self):
res = rst2html(text)
self.assertEqual(res, b'<p><strong>simple render</strong></p>')
self.assertEqual(rst2html(''), '')


class TestServiceDirective(TestCase):

def test_module_reload(self):
directive = ServiceDirective(
'test', [], {}, [], 1, 1, 'test', mock.Mock(), 1)
directive.options['modules'] = ['cornice']
directive.run()
directive.run()

0 comments on commit 6647ac4

Please sign in to comment.