launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #27628
[Merge] ~cjwatson/lp-codeimport:remove-doctestcodec into lp-codeimport:master
Colin Watson has proposed merging ~cjwatson/lp-codeimport:remove-doctestcodec into lp-codeimport:master.
Commit message:
Remove lp.services.testing.doctestcodec
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/lp-codeimport/+git/lp-codeimport/+merge/410813
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/lp-codeimport:remove-doctestcodec into lp-codeimport:master.
diff --git a/lib/lp/services/testing/__init__.py b/lib/lp/services/testing/__init__.py
index 8dc4594..dbbe4df 100644
--- a/lib/lp/services/testing/__init__.py
+++ b/lib/lp/services/testing/__init__.py
@@ -20,8 +20,6 @@ import logging
import os
import unittest
-# 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)