Move XML Name pattern to `epub3`

This commit is contained in:
Adam Turner
2022-09-10 09:04:35 +01:00
parent 5eb79c126a
commit f4ab9adf77
4 changed files with 31 additions and 35 deletions

View File

@@ -7,6 +7,8 @@ from xml.etree import ElementTree
import pytest
from sphinx.builders.epub3 import _XML_NAME_PATTERN
# check given command is runnable
def runnable(command):
@@ -382,3 +384,9 @@ def test_run_epubcheck(app):
print(exc.stdout.decode('utf-8'))
print(exc.stderr.decode('utf-8'))
raise AssertionError('epubcheck exited with return code %s' % exc.returncode)
def test_xml_name_pattern_check():
assert _XML_NAME_PATTERN.match('id-pub')
assert _XML_NAME_PATTERN.match('webpage')
assert not _XML_NAME_PATTERN.match('1bfda21')

View File

@@ -6,7 +6,7 @@ import tempfile
import pytest
from sphinx.errors import ExtensionError
from sphinx.util import encode_uri, ensuredir, import_object, parselinenos, xmlname_checker
from sphinx.util import encode_uri, ensuredir, import_object, parselinenos
def test_encode_uri():
@@ -75,10 +75,3 @@ def test_parselinenos():
parselinenos('-', 10)
with pytest.raises(ValueError):
parselinenos('3-1', 10)
def test_xmlname_check():
checker = xmlname_checker()
assert checker.match('id-pub')
assert checker.match('webpage')
assert not checker.match('1bfda21')