Skip to content

Commit

Permalink
TST: Test unusual class constructors (#135)
Browse files Browse the repository at this point in the history
Refs:
* #124
* 332d09a
  • Loading branch information
programmerjake authored and kernc committed Dec 10, 2019
1 parent 332d09a commit 86eac27
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pdoc/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def test_html_multiple_files(self):
def test_html_identifier(self):
for package in ('', '._private'):
with self.subTest(package=package), \
self.assertWarns(UserWarning) as cm:
self.assertWarns(UserWarning) as cm:
with run_html(EXAMPLE_MODULE + package, filter='A',
config='show_source_code=False'):
self._check_files(['A'], ['CONST', 'B docstring'])
Expand Down Expand Up @@ -379,6 +379,7 @@ class ApiTest(unittest.TestCase):
"""
Programmatic/API unit tests.
"""

def setUp(self):
pdoc.reset()

Expand All @@ -398,7 +399,7 @@ def test_module(self):

def test_import_filename(self):
with patch.object(sys, 'path', ['']), \
chdir(os.path.join(TESTS_BASEDIR, EXAMPLE_MODULE)):
chdir(os.path.join(TESTS_BASEDIR, EXAMPLE_MODULE)):
pdoc.import_module('index')

def test_imported_once(self):
Expand Down Expand Up @@ -702,6 +703,7 @@ def __init__(self):

class C:
"""foo"""

def __init__(self):
"""bar"""

Expand Down Expand Up @@ -730,6 +732,12 @@ def __init__(self, x):
with patch.dict(mod.obj.__pdoc__, {'C.__init__': False}):
self.assertEqual(pdoc.Class('C', mod, C).params(), [])

# test case for https://github.com/pdoc3/pdoc/issues/124
class C2:
__signature__ = inspect.signature(lambda a, b, c=None, *, d=1, e: None)

self.assertEqual(pdoc.Class('C2', mod, C2).params(), ['a', 'b', 'c=None', '*', 'd=1', 'e'])

def test_url(self):
mod = pdoc.Module(EXAMPLE_MODULE)
pdoc.link_inheritance()
Expand Down Expand Up @@ -782,6 +790,7 @@ class HtmlHelpersTest(unittest.TestCase):
"""
Unit tests for helper functions for producing HTML.
"""

def test_minify_css(self):
css = 'a { color: white; } /*comment*/ b {;}'
minified = minify_css(css)
Expand Down

0 comments on commit 86eac27

Please sign in to comment.