Only in the inspect tests, elsewhere it's counterproductive.
'FAVICON': None,
'LINKS_NAVBAR1': None,
'LINKS_NAVBAR2': None,
- # None instead of [] so we can detect even an empty override
- 'INPUT_MODULES': None,
'SEARCH_DISABLED': True,
'OUTPUT': os.path.join(self.path, 'output')
})
- # Update it with config overrides, specify the input module if not
- # already
+ # Update it with config overrides
config.update(config_overrides)
- if config['INPUT_MODULES'] is None:
- sys.path.append(self.path)
- config['INPUT_MODULES'] = [self.dirname]
run(self.path, config, templates=templates)
with open(os.path.join(self.path, 'output', actual)) as f:
actual_contents = f.read().strip()
return actual_contents, expected_contents
+
+class BaseInspectTestCase(BaseTestCase):
+ def run_python(self, config_overrides={}, templates=default_templates):
+ if 'INPUT_MODULES' not in config_overrides:
+ sys.path.append(self.path)
+
+ # Have to do a deep copy to avoid overwriting the parameter default
+ # value. UGH.
+ config = copy.deepcopy(config_overrides)
+ config['INPUT_MODULES'] = [self.dirname]
+ config_overrides = config
+
+ BaseTestCase.run_python(self, config_overrides, templates)
# DEALINGS IN THE SOFTWARE.
#
+import copy
import math
import os
import sys
from distutils.version import LooseVersion
-from . import BaseTestCase
+from python import default_templates
+from . import BaseInspectTestCase
-class String(BaseTestCase):
+class String(BaseInspectTestCase):
def __init__(self, *args, **kwargs):
super().__init__(__file__, 'string', *args, **kwargs)
self.assertEqual(*self.actual_expected_contents('classes.html'))
self.assertEqual(*self.actual_expected_contents('modules.html'))
-class Object(BaseTestCase):
+class Object(BaseInspectTestCase):
def __init__(self, *args, **kwargs):
super().__init__(__file__, 'object', *args, **kwargs)
self.assertEqual(*self.actual_expected_contents('classes.html', '../inspect_string/classes.html'))
self.assertEqual(*self.actual_expected_contents('modules.html', '../inspect_string/modules.html'))
-class AllProperty(BaseTestCase):
+class AllProperty(BaseInspectTestCase):
def __init__(self, *args, **kwargs):
super().__init__(__file__, 'all_property', *args, **kwargs)
self.run_python()
self.assertEqual(*self.actual_expected_contents('inspect_all_property.html'))
-class Annotations(BaseTestCase):
+class Annotations(BaseInspectTestCase):
def __init__(self, *args, **kwargs):
super().__init__(__file__, 'annotations', *args, **kwargs)
'PROJECT_TITLE': "A project",
'PROJECT_SUBTITLE': "is cool",
- 'INPUT_MODULES': [], # Explicitly none
-
'THEME_COLOR': '#00ffff',
'FAVICON': 'favicon-light.png',
'PAGE_HEADER': "`A self link <{filename}>`_",
from python import parse_pybind_signature
-from . import BaseTestCase
+from . import BaseInspectTestCase
class Signature(unittest.TestCase):
def test(self):
'(arg0: MyClass) -> float'),
('', '', [('arg0', 'MyClass', None)], 'float'))
-class Signatures(BaseTestCase):
+class Signatures(BaseInspectTestCase):
def __init__(self, *args, **kwargs):
super().__init__(__file__, 'signatures', *args, **kwargs)
self.assertEqual(*self.actual_expected_contents('pybind_signatures.html'))
self.assertEqual(*self.actual_expected_contents('pybind_signatures.MyClass.html'))
-class Enums(BaseTestCase):
+class Enums(BaseInspectTestCase):
def __init__(self, *args, **kwargs):
super().__init__(__file__, 'enums', *args, **kwargs)
})
self.assertEqual(*self.actual_expected_contents('pybind_enums.html'))
-class Submodules(BaseTestCase):
+class Submodules(BaseInspectTestCase):
def __init__(self, *args, **kwargs):
super().__init__(__file__, 'submodules', *args, **kwargs)