File: test_sphinxext.py

package info (click to toggle)
python-wsme 0.6-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 956 kB
  • ctags: 1,831
  • sloc: python: 8,452; makefile: 138
file content (45 lines) | stat: -rw-r--r-- 1,317 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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)')