Пример #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