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

zopefoundation / grokcore.layout / 16098815659

18 Jun 2025 06:34AM UTC coverage: 96.033%. Remained the same
16098815659

push

github

icemac
Back to development: 5.1

22 of 26 branches covered (84.62%)

Branch coverage included in aggregate %.

438 of 453 relevant lines covered (96.69%)

0.97 hits per line

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

92.86
/src/grokcore/layout/tests/layout/selectlayout.py
1
"""
2
  >>> one = One()
3

4
  >>> from zope.publisher.browser import TestRequest
5
  >>> from zope.component import getMultiAdapter
6

7
  >>> request = TestRequest()
8

9
We test that we can retrieve the default layout for the page that
10
doesn't select any specific layout::
11

12
  >>> view = getMultiAdapter((one, request), name="viewone")
13
  >>> print(view())
14
  Layout One
15

16
We test that we can retrieve the default layout for the page that
17
select a specific layout::
18

19
  >>> view = getMultiAdapter((one, request), name="viewtwo")
20
  >>> print(view())
21
  Layout Two
22

23
"""
24
import grokcore.view as grok
1✔
25
from zope.interface import Interface
1✔
26

27
from grokcore.layout import ILayout
1✔
28
from grokcore.layout import Layout
1✔
29
from grokcore.layout import Page
1✔
30
from grokcore.layout import layout
1✔
31

32

33
class One(grok.Context):
1✔
34
    pass
1✔
35

36

37
class LayoutOne(Layout):
1✔
38
    grok.context(One)
1✔
39

40
    def render(self):
1✔
41
        return "Layout One"
1✔
42

43

44
class ILayoutTwo(ILayout):
1✔
45
    pass
1✔
46

47

48
class LayoutTwo(Layout):
1✔
49
    grok.context(One)
1✔
50
    grok.provides(ILayoutTwo)
1✔
51

52
    def render(self):
1✔
53
        return "Layout Two"
1✔
54

55

56
class ViewOne(Page):
1✔
57
    grok.context(Interface)
1✔
58

59
    def render(self):
1✔
60
        return "MyView on regular layout"
×
61

62

63
class ViewTwo(Page):
1✔
64
    grok.context(Interface)
1✔
65
    layout(ILayoutTwo)
1✔
66

67
    def render(self):
1✔
68
        return "MyView on layout two"
×
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