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

zopefoundation / zope.dottedname / 16248941268

09 Aug 2024 04:26PM UTC coverage: 100.0%. Remained the same
16248941268

push

github

web-flow
Update Python version support. (#14)

8 of 8 branches covered (100.0%)

Branch coverage included in aggregate %.

4 of 4 new or added lines in 1 file covered. (100.0%)

63 of 63 relevant lines covered (100.0%)

1.0 hits per line

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

100.0
/src/zope/dottedname/tests.py
1
##############################################################################
2
#
3
# Copyright (c) 2004 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
"""test resolution of dotted names
15
"""
16
import unittest
1✔
17

18

19
class Test_resolve(unittest.TestCase):
1✔
20

21
    def _callFUT(self, *args, **kw):
1✔
22
        from zope.dottedname.resolve import resolve
1✔
23
        return resolve(*args, **kw)
1✔
24

25
    def test_no_dots_non_importable(self):
1✔
26
        self.assertRaises(ModuleNotFoundError, self._callFUT,
1✔
27
                          '_non_importable_module_')
28

29
    def test_no_dots(self):
1✔
30
        self.assertTrue(self._callFUT('unittest') is unittest)
1✔
31

32
    def test_module_attr_nonesuch(self):
1✔
33
        self.assertRaises(ModuleNotFoundError, self._callFUT,
1✔
34
                          'unittest.nonesuch')
35

36
    def test_module_attr(self):
1✔
37
        self.assertTrue(
1✔
38
            self._callFUT('unittest.TestCase') is unittest.TestCase)
39

40
    def test_submodule(self):
1✔
41
        from zope import dottedname
1✔
42
        self.assertTrue(self._callFUT('zope.dottedname') is dottedname)
1✔
43

44
    def test_submodule_not_yet_imported(self):
1✔
45
        import sys
1✔
46

47
        import zope.dottedname
1✔
48
        try:
1✔
49
            del sys.modules['zope.dottedname.example']
1✔
50
        except KeyError:
1✔
51
            pass
1✔
52
        try:
1✔
53
            del zope.dottedname.example
1✔
54
        except AttributeError:
1✔
55
            pass
1✔
56
        found = self._callFUT('zope.dottedname.example')
1✔
57
        self.assertTrue(found is sys.modules['zope.dottedname.example'])
1✔
58

59
    def test_submodule_attr(self):
1✔
60
        from zope.dottedname.resolve import resolve
1✔
61
        self.assertTrue(
1✔
62
            self._callFUT('zope.dottedname.resolve.resolve') is resolve)
63

64
    def test_relative_no_module(self):
1✔
65
        self.assertRaises(ValueError, self._callFUT, '.resolve')
1✔
66

67
    def test_relative_w_module(self):
1✔
68
        from zope.dottedname.resolve import resolve
1✔
69
        self.assertTrue(
1✔
70
            self._callFUT('.resolve.resolve', 'zope.dottedname') is resolve)
71

72
    def test_relative_w_module_multiple_dots(self):
1✔
73
        from zope.dottedname import resolve
1✔
74
        self.assertTrue(
1✔
75
            self._callFUT('..resolve', 'zope.dottedname.tests') is resolve)
76

77

78
def test_suite():
1✔
79
    return unittest.TestSuite(
1✔
80
        (unittest.defaultTestLoader.loadTestsFromTestCase(Test_resolve), ))
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