Skip to content

Commit 86eac27

Browse files
programmerjakekernc
authored andcommitted
TST: Test unusual class constructors (#135)
Refs: * #124 * 332d09a
1 parent 332d09a commit 86eac27

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

pdoc/test/__init__.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def test_html_multiple_files(self):
209209
def test_html_identifier(self):
210210
for package in ('', '._private'):
211211
with self.subTest(package=package), \
212-
self.assertWarns(UserWarning) as cm:
212+
self.assertWarns(UserWarning) as cm:
213213
with run_html(EXAMPLE_MODULE + package, filter='A',
214214
config='show_source_code=False'):
215215
self._check_files(['A'], ['CONST', 'B docstring'])
@@ -379,6 +379,7 @@ class ApiTest(unittest.TestCase):
379379
"""
380380
Programmatic/API unit tests.
381381
"""
382+
382383
def setUp(self):
383384
pdoc.reset()
384385

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

399400
def test_import_filename(self):
400401
with patch.object(sys, 'path', ['']), \
401-
chdir(os.path.join(TESTS_BASEDIR, EXAMPLE_MODULE)):
402+
chdir(os.path.join(TESTS_BASEDIR, EXAMPLE_MODULE)):
402403
pdoc.import_module('index')
403404

404405
def test_imported_once(self):
@@ -702,6 +703,7 @@ def __init__(self):
702703

703704
class C:
704705
"""foo"""
706+
705707
def __init__(self):
706708
"""bar"""
707709

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

735+
# test case for https://github.com/pdoc3/pdoc/issues/124
736+
class C2:
737+
__signature__ = inspect.signature(lambda a, b, c=None, *, d=1, e: None)
738+
739+
self.assertEqual(pdoc.Class('C2', mod, C2).params(), ['a', 'b', 'c=None', '*', 'd=1', 'e'])
740+
733741
def test_url(self):
734742
mod = pdoc.Module(EXAMPLE_MODULE)
735743
pdoc.link_inheritance()
@@ -782,6 +790,7 @@ class HtmlHelpersTest(unittest.TestCase):
782790
"""
783791
Unit tests for helper functions for producing HTML.
784792
"""
793+
785794
def test_minify_css(self):
786795
css = 'a { color: white; } /*comment*/ b {;}'
787796
minified = minify_css(css)

0 commit comments

Comments
 (0)