From 86eac27b52c0dedf3ccba4d49b7ecb568341df44 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Tue, 10 Dec 2019 05:27:58 -0800 Subject: [PATCH] TST: Test unusual class constructors (#135) Refs: * https://github.com/pdoc3/pdoc/issues/124 * https://github.com/pdoc3/pdoc/commit/332d09ac4a258bf69caa5597f797814977b2f9bd --- pdoc/test/__init__.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pdoc/test/__init__.py b/pdoc/test/__init__.py index fe198c66..4674b60f 100644 --- a/pdoc/test/__init__.py +++ b/pdoc/test/__init__.py @@ -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']) @@ -379,6 +379,7 @@ class ApiTest(unittest.TestCase): """ Programmatic/API unit tests. """ + def setUp(self): pdoc.reset() @@ -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): @@ -702,6 +703,7 @@ def __init__(self): class C: """foo""" + def __init__(self): """bar""" @@ -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() @@ -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)