mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Make headerregistry fully part of the provisional api.
When I made the checkin of the provisional email policy, I knew that Address and Group needed to be made accessible from somewhere. The more I looked at it, though, the more it became clear that since this is a provisional API anyway, there's no good reason to hide headerregistry as a private API. It was designed to ultimately be part of the public API, and so it should be part of the provisional API. This patch fully documents the headerregistry API, and deletes the abbreviated version of those docs I had added to the provisional policy docs.
This commit is contained in:
parent
393da3240a
commit
ea9766897b
7 changed files with 429 additions and 213 deletions
|
@ -5,7 +5,7 @@ import unittest
|
|||
import email.policy
|
||||
import email.parser
|
||||
import email.generator
|
||||
from email import _headerregistry
|
||||
from email import headerregistry
|
||||
|
||||
def make_defaults(base_defaults, differences):
|
||||
defaults = base_defaults.copy()
|
||||
|
@ -185,11 +185,11 @@ class PolicyAPITests(unittest.TestCase):
|
|||
def test_default_header_factory(self):
|
||||
h = email.policy.default.header_factory('Test', 'test')
|
||||
self.assertEqual(h.name, 'Test')
|
||||
self.assertIsInstance(h, _headerregistry.UnstructuredHeader)
|
||||
self.assertIsInstance(h, _headerregistry.BaseHeader)
|
||||
self.assertIsInstance(h, headerregistry.UnstructuredHeader)
|
||||
self.assertIsInstance(h, headerregistry.BaseHeader)
|
||||
|
||||
class Foo:
|
||||
parse = _headerregistry.UnstructuredHeader.parse
|
||||
parse = headerregistry.UnstructuredHeader.parse
|
||||
|
||||
def test_each_Policy_gets_unique_factory(self):
|
||||
policy1 = email.policy.EmailPolicy()
|
||||
|
@ -197,10 +197,10 @@ class PolicyAPITests(unittest.TestCase):
|
|||
policy1.header_factory.map_to_type('foo', self.Foo)
|
||||
h = policy1.header_factory('foo', 'test')
|
||||
self.assertIsInstance(h, self.Foo)
|
||||
self.assertNotIsInstance(h, _headerregistry.UnstructuredHeader)
|
||||
self.assertNotIsInstance(h, headerregistry.UnstructuredHeader)
|
||||
h = policy2.header_factory('foo', 'test')
|
||||
self.assertNotIsInstance(h, self.Foo)
|
||||
self.assertIsInstance(h, _headerregistry.UnstructuredHeader)
|
||||
self.assertIsInstance(h, headerregistry.UnstructuredHeader)
|
||||
|
||||
def test_clone_copies_factory(self):
|
||||
policy1 = email.policy.EmailPolicy()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue