Skip to content
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

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

Closed
wants to merge 4 commits into from

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Jan 20, 2024

There should be a lot of changed files, but history should be clean.


📚 Documentation preview 📚: https://cpython-previews--114344.org.readthedocs.build/

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_xmlrpc and test_docxmlrpc are not XML tests.

@vstinner
Copy link
Member

Hum, I don't get the PR description. So, what it does:

Create test_xml test package

* Create a new test_xml test package.
* Declare test_xml as a test package in libregrtest (findtests.py).
* Move the 7 tests to test_xml: test_minidom.py, test_pulldom.py,
  test_pyexpat.py, test_sax.py, test_xml_dom_minicompat.py,
  test_xml_etree_c.py and test_xml_etree.py.
* Move Lib/test/xmltestdata/ to Lib/test/test_xml/xmltestdata/.

It changes also findfile() of test.support: if subdir is not a string, use os.path.join(subdir). Is the findfile() needed? One option would to be avoid one level of directories: move the 5 test files from Lib/test/test_xml/xmltestdata/ to Lib/test/test_xml/ as done in other test packages. But keep c14n-20/ in a subdirectory.

What do you think about removing xmltestdata/ subdirectory @sobolevn?

@serhiy-storchaka
Copy link
Member

I do not think that it is worth to do. Unlike to asyncio or email, xml is not a single package. It is a set of unrelated packages in a common parent namespace.

@sobolevn
Copy link
Member Author

@serhiy-storchaka sorry, I don't agree. They might have any implementation details, but they are still sharing the same namespace and they use the same fixture files. It is logical for test to have the same namespaces as regular code does.

@sobolevn sobolevn force-pushed the issue-108303-test_xml branch from af1b057 to 13fdbc7 Compare January 23, 2024 10:27
@sobolevn
Copy link
Member Author

@vstinner I tried to remove xmltestdata/ directory, but I didn't go too well.
Since it relies on some exotic line-ending rules and possibly other magic stuff, I would say that keeping it as-is the same simplest and the safest thing we can do.

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to close this issue.

There are different aspects:

  • Is it possible to run individual tests separately? Like test_xml.test_test_minidom. Yes, it's possible.
  • Does the change increase parallelism of tests, or make it worse? Same, since regrtest splits test_xml into sub-tests to run them in parallel.
  • Are these sub-tests related? How? Well, there are related to "XML". Their implementations are unrelated. xml.minidom implementation has nothing to do with xml.etree.

@sobolevn:

they are still sharing the same namespace and they use the same fixture files. It is logical for test to have the same namespaces as regular code does.

We have many "os-like" and "socket-like" tests in separated tests, and that's why we have helpers such as support.os_helper and support.socket_helper. I don't buy the argument "putting everything at the same place is better".

While it's very tempting to put "everything related to XML" in a test package, for this change, I prefer to stick to the status quo: "flat namespace is better than nested" (PEP 20) :-)

Not changing tests keeps the Git history linear (no custom command line option needed) and avoids developers to change their habits. I don't think that the benefits are way higher than drawbacks (moving code).

Test files are already in the xmltestdata directory.

@bedevere-app
Copy link

bedevere-app bot commented Jan 23, 2024

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@sobolevn
Copy link
Member Author

Ok, sounds convincing 👍

@sobolevn sobolevn closed this Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants