• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zopefoundation / grokcore.component / 16098871523

18 Jun 2025 06:24AM UTC coverage: 96.224%. Remained the same
16098871523

push

github

icemac
Back to development: 5.1

113 of 136 branches covered (83.09%)

Branch coverage included in aggregate %.

1416 of 1453 relevant lines covered (97.45%)

0.97 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.0
/src/grokcore/component/testing.py
1
##############################################################################
2
#
3
# Copyright (c) 2007 Zope Foundation and Contributors.
4
# All Rights Reserved.
5
#
6
# This software is subject to the provisions of the Zope Public License,
7
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
8
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
9
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
11
# FOR A PARTICULAR PURPOSE.
12
#
13
##############################################################################
14
"""Grok test helpers
15
"""
16
from martian import scan
1✔
17
from zope.configuration.config import ConfigurationMachine
1✔
18

19
import grokcore.component
1✔
20
from grokcore.component import zcml
1✔
21

22

23
def grok(*module_names):
1✔
24
    config = ConfigurationMachine()
1✔
25
    zcml.do_grok('grokcore.component.compat', config)
1✔
26
    zcml.do_grok('grokcore.component.meta', config)
1✔
27
    for module_name in module_names:
1✔
28
        zcml.do_grok(module_name, config)
1✔
29
    config.execute_actions()
1✔
30

31

32
def grok_component(name, component,
1✔
33
                   context=None, module_info=None, templates=None,
34
                   dotted_name=None):
35
    if module_info is None:
1!
36
        if dotted_name is None:
1✔
37
            dotted_name = getattr(component, '__grok_module__', None)
1✔
38
            if dotted_name is None:
1!
39
                dotted_name = getattr(component, '__module__', None)
1✔
40
            module_info = scan.module_info_from_dotted_name(dotted_name)
1✔
41
        module_info = scan.module_info_from_dotted_name(dotted_name)
1✔
42

43
    module = module_info.getModule()
1✔
44
    if context is not None:
1✔
45
        grokcore.component.context.set(module, context)
1✔
46
    if templates is not None:
1!
47
        module.__grok_templates__ = templates
×
48
    config = ConfigurationMachine()
1✔
49
    result = zcml.the_multi_grokker.grok(name, component,
1✔
50
                                         module_info=module_info,
51
                                         config=config)
52
    config.execute_actions()
1✔
53
    return result
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc