Skip to content

gh-108303: Move all XML-related test files to test_xml #114344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Lib/test/decimaltestdata/*.decTest noeol
Lib/test/test_email/data/*.txt noeol
Lib/test/test_importlib/resources/data01/* noeol
Lib/test/test_importlib/resources/namespacedata01/* noeol
Lib/test/xmltestdata/* noeol
Lib/test/test_xml/xmltestdata/* noeol

# Shell scripts should have LF even on Windows because of Cygwin
Lib/venv/scripts/common/activate text eol=lf
Expand Down
2 changes: 1 addition & 1 deletion Doc/license.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ W3C C14N test suite
-------------------

The C14N 2.0 test suite in the :mod:`test` package
(``Lib/test/xmltestdata/c14n-20/``) was retrieved from the W3C website at
(``Lib/test/test_xml/xmltestdata/c14n-20/``) was retrieved from the W3C website at
https://www.w3.org/TR/xml-c14n2-testcases/ and is distributed under the
3-clause BSD license::

Expand Down
1 change: 1 addition & 0 deletions Lib/test/libregrtest/findtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"test_multiprocessing_fork",
"test_multiprocessing_forkserver",
"test_multiprocessing_spawn",
"test_xml",
}


Expand Down
4 changes: 4 additions & 0 deletions Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,14 @@ def findfile(filename, subdir=None):

Setting *subdir* indicates a relative path to use to find the file
rather than looking directly in the path directories.
It can be either a string or a tuple of strings,
which will be joined with the correct path separator.
"""
if os.path.isabs(filename):
return filename
if subdir is not None:
if isinstance(subdir, tuple):
subdir = os.path.join(*subdir)
filename = os.path.join(subdir, filename)
path = [TEST_HOME_DIR] + sys.path
for dn in path:
Expand Down
5 changes: 5 additions & 0 deletions Lib/test/test_xml/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import os
from test.support import load_package_tests

def load_tests(*args):
return load_package_tests(os.path.dirname(__file__), *args)
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from xml.parsers.expat import ExpatError


tstfile = support.findfile("test.xml", subdir="xmltestdata")
tstfile = support.findfile("test.xml", subdir=("test_xml", "xmltestdata"))
sample = ("<?xml version='1.0' encoding='us-ascii'?>\n"
"<!DOCTYPE doc PUBLIC 'http://xml.python.org/public'"
" 'http://xml.python.org/system' [\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from test.support import findfile


tstfile = findfile("test.xml", subdir="xmltestdata")
tstfile = findfile("test.xml", subdir=("test_xml", "xmltestdata"))

# A handy XML snippet, containing attributes, a namespace prefix, and a
# self-closing tag:
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions Lib/test/test_sax.py → Lib/test/test_xml/test_sax.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
from test.support.os_helper import FakePath, TESTFN


TEST_XMLFILE = findfile("test.xml", subdir="xmltestdata")
TEST_XMLFILE_OUT = findfile("test.xml.out", subdir="xmltestdata")
TEST_XMLFILE = findfile("test.xml", subdir=("test_xml", "xmltestdata"))
TEST_XMLFILE_OUT = findfile("test.xml.out", subdir=("test_xml", "xmltestdata"))
try:
TEST_XMLFILE.encode("utf-8")
TEST_XMLFILE_OUT.encode("utf-8")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
pyET = None
ET = None

SIMPLE_XMLFILE = findfile("simple.xml", subdir="xmltestdata")
SIMPLE_XMLFILE = findfile("simple.xml", subdir=("test_xml", "xmltestdata"))
try:
SIMPLE_XMLFILE.encode("utf-8")
except UnicodeEncodeError:
raise unittest.SkipTest("filename is not encodable to utf8")
SIMPLE_NS_XMLFILE = findfile("simple-ns.xml", subdir="xmltestdata")
UTF8_BUG_XMLFILE = findfile("expat224_utf8_bug.xml", subdir="xmltestdata")
SIMPLE_NS_XMLFILE = findfile("simple-ns.xml", subdir=("test_xml", "xmltestdata"))
UTF8_BUG_XMLFILE = findfile("expat224_utf8_bug.xml", subdir=("test_xml", "xmltestdata"))

SAMPLE_XML = """\
<body>
Expand Down Expand Up @@ -4094,7 +4094,7 @@ def test_c14n_exclusion(self):
# output, not roundtripped C14N (see above).

def test_xml_c14n2(self):
datadir = findfile("c14n-20", subdir="xmltestdata")
datadir = findfile("c14n-20", subdir=("test_xml", "xmltestdata"))
full_path = partial(os.path.join, datadir)

files = [filename[:-4] for filename in sorted(os.listdir(datadir))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def test_element_with_children(self):

def install_tests():
# Test classes should have __module__ referring to this module.
from test import test_xml_etree
from test.test_xml import test_xml_etree
for name, base in vars(test_xml_etree).items():
if isinstance(base, type) and issubclass(base, unittest.TestCase):
class Temp(base):
Expand All @@ -270,7 +270,7 @@ class Temp(base):
install_tests()

def setUpModule():
from test import test_xml_etree
from test.test_xml import test_xml_etree
test_xml_etree.setUpModule(module=cET)


Expand Down
File renamed without changes.
21 changes: 0 additions & 21 deletions Lib/test/xmltests.py

This file was deleted.

5 changes: 3 additions & 2 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -2317,8 +2317,9 @@ TESTSUBDIRS= idlelib/idle_test \
test/tokenizedata \
test/tracedmodules \
test/typinganndata \
test/xmltestdata \
test/xmltestdata/c14n-20
test/test_xml \
test/test_xml/xmltestdata \
test/test_xml/xmltestdata/c14n-20

COMPILEALL_OPTS=-j0

Expand Down