wsme/tests/test_sphinxext.py
Christophe de Vienne 8736089dc9 Moved non-core features to the wsmeext namespace package
--HG--
rename : wsme/cornice.py => wsmeext/cornice.py
rename : wsme/pecan.py => wsmeext/pecan.py
rename : wsme/sphinxext.py => wsmeext/sphinxext.py
rename : wsme/tg1.py => wsmeext/tg1.py
rename : wsme/tg11.py => wsmeext/tg11.py
rename : wsme/tg15.py => wsmeext/tg15.py
2013-01-17 13:15:25 +01:00

46 lines
1.3 KiB
Python

import unittest
import sphinx
import os.path
import wsme.types
from wsmeext import sphinxext
docpath = os.path.join(
os.path.dirname(__file__),
'sphinxexample')
class ASampleType(object):
somebytes = wsme.types.bytes
sometext = wsme.types.text
someint = int
class TestSphinxExt(unittest.TestCase):
def test_buildhtml(self):
if not os.path.exists('.test_sphinxext/'):
os.makedirs('.test_sphinxext/')
assert sphinx.main(['',
'-b', 'html',
'-d', '.test_sphinxext/doctree',
docpath,
'.test_sphinxext/html']) == 0
class TestDataTypeName(unittest.TestCase):
def test_user_type(self):
self.assertEqual(sphinxext.datatypename(ASampleType),
'ASampleType')
def test_dict_type(self):
d = wsme.types.DictType(str, str)
self.assertEqual(sphinxext.datatypename(d), 'dict(str: str)')
d = wsme.types.DictType(str, ASampleType)
self.assertEqual(sphinxext.datatypename(d), 'dict(str: ASampleType)')
def test_array_type(self):
d = wsme.types.ArrayType(str)
self.assertEqual(sphinxext.datatypename(d), 'list(str)')
d = wsme.types.ArrayType(ASampleType)
self.assertEqual(sphinxext.datatypename(d), 'list(ASampleType)')