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

zopefoundation / z3c.testing / 6447486104

18 Jan 2023 07:44AM UTC coverage: 41.841% (-0.2%) from 42.083%
6447486104

push

github

web-flow
Config with pure python template (#8)

* Drop support for Python 2.7, 3.5, 3.6.
* Add support for Python 3.11.

9 of 32 branches covered (0.0%)

Branch coverage included in aggregate %.

7 of 7 new or added lines in 4 files covered. (100.0%)

91 of 207 relevant lines covered (43.96%)

0.44 hits per line

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

7.32
/src/z3c/testing/generation.py
1
###############################################################################
2
#
3
# Copyright 2006 by refline (Schweiz) AG, CH-5630 Muri
4
#
5
###############################################################################
6
import doctest
1✔
7
import os
1✔
8

9
from ZODB.DB import DB
1✔
10
from ZODB.DemoStorage import DemoStorage
×
11
from ZODB.FileStorage import FileStorage
×
12
from zope.app.publication.zopepublication import ZopePublication
×
13
from zope.app.testing import setup
×
14

15

16
###############################################################################
17
#
18
# Test component
19
#
20
###############################################################################
21

22
class ContextStub:
×
23
    """Stub for the context argument passed to evolve scripts.
24

25
    >>> from zope.app.zopeappgenerations import getRootFolder
26
    >>> context = ContextStub()
27
    >>> getRootFolder(context) is context.root_folder
28
    True
29

30
    """
31

32
    class ConnectionStub:
×
33
        def __init__(self, root_folder, db):
×
34
            self.root_folder = root_folder
×
35
            self.db = db
×
36

37
        def root(self):
×
38
            return {ZopePublication.root_name: self.root_folder}
×
39

40
        @property
×
41
        def _storage(self):
×
42
            return self.db._storage._base
×
43

44
        def get(self, oid):
×
45
            return self.db.open().get(oid)
×
46

47
    def __init__(self, rootFolder, db):
×
48
        self.root_folder = rootFolder
×
49
        self.connection = self.ConnectionStub(self.root_folder, db)
×
50

51

52
def getDBRoot(db):
×
53
    """Return the Zope root folder."""
54
    connection = db.open()
×
55
    root = connection.root()
×
56
    return root[ZopePublication.root_name]
×
57

58

59
def getDB(filename, package=None):
×
60
    """Return a DB by it's path."""
61
    if package is not None:
×
62
        filename = doctest._module_relative_path(package, filename)
×
63
        package = package.__file__
×
64
    else:
65
        package = __file__
×
66
    filename = os.path.join(os.path.dirname(package), filename)
×
67
    fileStorage = FileStorage(filename)
×
68
    storage = DemoStorage("Demo Storage", fileStorage)
×
69
    return DB(storage)
×
70

71

72
###############################################################################
73
#
74
# Test setup
75
#
76
###############################################################################
77

78
def setUpGeneration(test):
×
79
    setup.placefulSetUp()
×
80

81

82
def tearDownGeneration(test):
×
83
    setup.placefulTearDown()
×
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