Back to index

plone3  3.1.7
Public Member Functions
MimetypesRegistry.tests.test_encoding.TestGuessEncoding Class Reference
Inheritance diagram for MimetypesRegistry.tests.test_encoding.TestGuessEncoding:
Inheritance graph
[legend]
Collaboration diagram for MimetypesRegistry.tests.test_encoding.TestGuessEncoding:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def testUTF8
def testEmacs
def testVim
def testXML
def testHTML
def test_broken_percent

Detailed Description

Definition at line 7 of file test_encoding.py.


Member Function Documentation

Definition at line 76 of file test_encoding.py.

00076 
00077     def test_broken_percent(self):
00078         e = guess_encoding(
00079 r"""<pre>
00080 &lt;metal:block tal:define="dummy python:
00081 request.RESPONSE.setHeader('Content-Type',
00082 'text/html;;charset=%s' % charset)" /&gt;
00083 &lt;metal:block tal:define="dummy
00084 python:request.RESPONSE.setHeader('Content-Language', lang)"
00085 /
00086 &gt;
00087 </pre>
"""

Definition at line 15 of file test_encoding.py.

00015 
00016     def testEmacs(self):
00017         e = guess_encoding('# -*- coding: UTF-8  -*-')
00018         self.failUnlessEqual(e, 'UTF-8')
00019         e = guess_encoding('''
00020         ### -*- coding: ISO-8859-1  -*-
00021         ''')
00022         self.failUnlessEqual(e, 'ISO-8859-1')
00023         e = guess_encoding('''
00024 
00025         ### -*- coding: ISO-8859-1  -*-
00026         ''')
00027         self.failUnlessEqual(e, None)

Definition at line 55 of file test_encoding.py.

00055 
00056     def testHTML(self):
00057         e = guess_encoding('''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
00058 <html>
00059 <head>
00060 <title>ASPN : Python Cookbook : Auto-detect XML encoding</title>
00061     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
00062     <meta name="robots" content="all" />
00063     <meta name="description" content="ActiveState Open Source Programming tools for Perl Python XML xslt scripting with free trials. Quality development tools for programmers systems administrators database administrators network administrators and webmasters" />
00064     <meta name="keywords" content="ActiveState,Perl,xml,xslt,mozilla,Open Source,Python,Perl for Win32,resources,PerlScript,ActivePerl,Programming,Programmers,Integrated,Development,Environment,SOAP,Linux,Solaris,Web,development,tools,free,software,download,support,Perl Resource Kit,System Administration,Sys Admin,WinNT,SQL,Oracle,Email,XML,Linux,Programming,perl,NT,2000,windows,Unix,Software,Security,   Administration,systems,windows,database,database,consulting,support,Microsoft,developer,resource,code,tutorials,IDE,Integrated development environment,developer,resources,tcl,php" />
00065 
00066 <link rel="stylesheet" href="/ASPN/aspn.css" />
00067 
00068 </head>
00069 
00070 <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
00071 charset=utf-8
00072 </body>
00073 </html> ''')
00074         self.failUnlessEqual(e, 'iso-8859-1')
00075 

Definition at line 9 of file test_encoding.py.

00009 
00010     def testUTF8(self):
00011         e = guess_encoding('\xef\xbb\xbf any UTF-8 data')
00012         self.failUnlessEqual(e, 'UTF-8')
00013         e = guess_encoding(' any UTF-8 data \xef\xbb\xbf')
00014         self.failUnlessEqual(e, None)

Definition at line 28 of file test_encoding.py.

00028 
00029     def testVim(self):
00030         e = guess_encoding('# vim:fileencoding=UTF-8')
00031         self.failUnlessEqual(e, 'UTF-8')
00032         e = guess_encoding('''
00033         ### vim:fileencoding=ISO-8859-1
00034         ''')
00035         self.failUnlessEqual(e, 'ISO-8859-1')
00036         e = guess_encoding('''
00037 
00038         ### vim:fileencoding= ISO-8859-1
00039         ''')
00040         self.failUnlessEqual(e, None)

Definition at line 41 of file test_encoding.py.

00041 
00042     def testXML(self):
00043         e = guess_encoding('<?xml?>')
00044         self.failUnlessEqual(e, 'UTF-8')
00045         e = guess_encoding('''<?xml version="1.0" encoding="ISO-8859-1" ?>
00046         ''')
00047         self.failUnlessEqual(e, 'ISO-8859-1')
00048         e = guess_encoding('''<?xml version="1.0" encoding="ISO-8859-1"?>
00049         ''')
00050         self.failUnlessEqual(e, 'ISO-8859-1')
00051         e = guess_encoding('''<?xml version="1.0" encoding="ISO-8859-1"?><truc encoding="UTF-8">
00052         </truc>
00053         ''')
00054         self.failUnlessEqual(e, 'ISO-8859-1')


The documentation for this class was generated from the following file: