launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #26094
[Merge] ~cjwatson/launchpad:remove-doctestcodec into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:remove-doctestcodec into launchpad:master.
Commit message:
Remove lp.services.testing.doctestcodec
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/396833
It doesn't seem to be used anywhere, and nowadays we can generally just use Unicode directly.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:remove-doctestcodec into launchpad:master.
diff --git a/lib/lp/services/testing/__init__.py b/lib/lp/services/testing/__init__.py
index 540c8bd..0cc4713 100644
--- a/lib/lp/services/testing/__init__.py
+++ b/lib/lp/services/testing/__init__.py
@@ -23,8 +23,6 @@ import unittest
import scandir
-# This import registers the 'doctest' Unicode codec.
-import lp.services.testing.doctestcodec
from lp.testing.systemdocs import (
LayeredDocFileSuite,
setUp,
diff --git a/lib/lp/services/testing/doctestcodec.py b/lib/lp/services/testing/doctestcodec.py
deleted file mode 100644
index 29736b0..0000000
--- a/lib/lp/services/testing/doctestcodec.py
+++ /dev/null
@@ -1,60 +0,0 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-"""Codecs to convert Unicode strings to more human readable representations.
-
-Defines the 'doctest' encoding. This is ASCII, with Unicode characters
-represented using the standard Python \N{YEN SIGN} syntax.
-"""
-
-__metaclass__ = type
-__all__ = []
-
-import codecs
-import unicodedata
-
-
-def doctest_unicode_error_handler(error):
- r"""Codec error handler for doctests, registered as 'doctest'.
-
- >>> unicode_string = u"I \N{BLACK HEART SUIT}\N{YEN SIGN}!"
- >>> print unicode_string.encode('ascii', 'doctest')
- I \N{BLACK HEART SUIT}\N{YEN SIGN}!
- """
- replacement = []
- for char in error.object[error.start:error.end]:
- replacement.append(u"\\N{%s}" % unicodedata.name(char, '<UNNAMED>'))
- return (u''.join(replacement), error.end)
-
-
-def doctest_unicode_encode(input, errors='strict'):
- r"""Encoder to convert Unicode to 'doctest' format.
-
- >>> unicode_string = u"I \N{BLACK HEART SUIT}\N{YEN SIGN}!"
- >>> print unicode_string.encode('doctest')
- I \N{BLACK HEART SUIT}\N{YEN SIGN}!
- """
- return (input.encode('ASCII', 'doctest'), len(input))
-
-
-def doctest_unicode_decode(input, errors='strict'):
- r"""Decoder to convert from 'doctest' encoding to Unicode.
-
- >>> unicode_string = u"I \N{BLACK HEART SUIT}\N{YEN SIGN}!"
- >>> doctest_string = unicode_string.encode('doctest')
- >>> print doctest_string
- I \N{BLACK HEART SUIT}\N{YEN SIGN}!
- >>> roundtrip_string = doctest_string.decode('doctest')
- >>> roundtrip_string == unicode_string
- True
- """
- return (input.decode('unicode_escape', errors), len(input))
-
-
-def doctest_unicode_search(encoding_name):
- """Codec search function for the 'doctest' codec."""
- if encoding_name == 'doctest':
- return (doctest_unicode_encode, doctest_unicode_decode, None, None)
-
-codecs.register_error('doctest', doctest_unicode_error_handler)
-codecs.register(doctest_unicode_search)
diff --git a/lib/lp/services/testing/tests/test_doctestcodec.py b/lib/lp/services/testing/tests/test_doctestcodec.py
deleted file mode 100644
index 1f42e7b..0000000
--- a/lib/lp/services/testing/tests/test_doctestcodec.py
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-"""Tests for the doctestcodec module."""
-
-__metaclass__ = type
-__all__ = []
-
-from doctest import DocTestSuite
-
-import lp.services.testing.doctestcodec
-
-
-def test_suite():
- return DocTestSuite(lp.services.testing.doctestcodec)