コード例 #1
0
 def test_default_xhtml(self):
     # make sure by default we get XHTML output from HTML.
     proc = Tidy()
     self.resultpath, metadata = proc.process(
         self.sample_path, {'error': False})
     contents = open(self.resultpath, 'rb').read()
     assert 'xmlns="http://www.w3.org/1999/xhtml"' in contents
コード例 #2
0
 def test_default_xhtml(self, workdir, samples_dir):
     # make sure by default we get XHTML output from HTML.
     samples_dir.join("sample1.html").copy(workdir / "src" / "sample.html")
     proc = Tidy()
     resultpath, metadata = proc.process(
         str(workdir / "src" / "sample.html"), {'error': False})
     contents = open(resultpath, 'rb').read()
     assert b'xmlns="http://www.w3.org/1999/xhtml"' in contents
コード例 #3
0
 def test_encoding_utf8(self):
     # make sure we get UTF-8 output and no special stuff.
     proc = Tidy()
     self.resultpath, metadata = proc.process(
         self.sample_path, {'error': False})
     contents = open(self.resultpath, 'rb').read()
     assert 'Ü' in contents
     assert 'Ü' not in contents
コード例 #4
0
 def test_non_html_ignored(self, workdir):
     # we do not try to tidy non html/xhtml files
     proc = Tidy()
     sample_path = workdir / "sample.txt"
     sample_path.write('Sample file.')
     resultpath, metadata = proc.process(str(sample_path), {'error': False})
     # the document path hasn't changed
     assert resultpath == str(sample_path)
コード例 #5
0
 def test_default_xhtml(self, workdir, samples_dir):
     # make sure by default we get XHTML output from HTML.
     samples_dir.join("sample1.html").copy(workdir / "src" / "sample.html")
     proc = Tidy()
     resultpath, metadata = proc.process(
         str(workdir / "src" / "sample.html"), {'error': False})
     contents = open(resultpath, 'rb').read()
     assert b'xmlns="http://www.w3.org/1999/xhtml"' in contents
コード例 #6
0
 def test_non_html_ignored(self, workdir):
     # we do not try to tidy non html/xhtml files
     proc = Tidy()
     sample_path = workdir / "sample.txt"
     sample_path.write('Sample file.')
     resultpath, metadata = proc.process(
         str(sample_path), {'error': False})
     # the document path hasn't changed
     assert resultpath == str(sample_path)
コード例 #7
0
 def test_encoding_utf8(self, workdir, samples_dir):
     # make sure we get UTF-8 output and no special stuff.
     samples_dir.join("sample1.html").copy(workdir / "src" / "sample.html")
     proc = Tidy()
     resultpath, metadata = proc.process(
         str(workdir / "src" / "sample.html"), {'error': False})
     contents = codecs.open(resultpath, 'r', encoding='utf-8').read()
     assert u'Ü' in contents
     assert u'Ü' not in contents
コード例 #8
0
 def test_non_html_ignored(self):
     # we do not try to tidy non html/xhtml files
     proc = Tidy()
     sample_path = os.path.join(self.workdir, 'sample.txt')
     open(sample_path, 'w').write('Sample file.')
     self.resultpath, metadata = proc.process(
         sample_path, {'error': False})
     # the document path hasn't changed
     assert self.resultpath == sample_path
コード例 #9
0
 def test_encoding_utf8(self, workdir, samples_dir):
     # make sure we get UTF-8 output and no special stuff.
     samples_dir.join("sample1.html").copy(workdir / "src" / "sample.html")
     proc = Tidy()
     resultpath, metadata = proc.process(
         str(workdir / "src" / "sample.html"), {'error': False})
     contents = codecs.open(resultpath, 'r', encoding='utf-8').read()
     assert u'Ü' in contents
     assert u'Ü' not in contents