Skip to content

Conversation

surister
Copy link
Member

@surister surister commented Oct 14, 2025

This pr attempts to modernize the project by:

  • Making use of pyproject.toml moving away from setup.py
  • Use modern build tool like hatchling moving away from buildout
  • Make it possible to run tests with just pytest moving away from zope and unittests
  • Simplify development setup to work with uv and any other pyproject.toml compatible tool
  • Simplify versioning by using hatchling dynamic versioning moving away from setup.py shenanigans
  • Simplifying tests by moving away from the custom Testlayer to testcontainers

Changes

  • Migrate all metadata from setup.py to pyproject.toml
  • Make project installable with uv and other venv tools.
  • Make project buildable with both uv build and python -m build
  • Migrate test_cursor to pytest
  • Migrate test_connection to pytest
  • Migrate test_exception to pytest
  • Migrate test_http to pytest
  • Migrate test_cursor to pytest
  • Migrate doctests to pytest
  • Migrate testlayer to testcontainers

Aditional changes

  • Every tests has a docstring explaining what's expected of the test.
  • test files like test_http are split into smaller tests files, in this case, there are tests that test the http.Client and the serialization of data, the new scheme will phase test_http into test_serialization and test_client. This is just to give an idea of what the change is like, might actually differ later.

Notes to remember:

  • serializers testing have been revamped, now we only test the serialization call chain and then test the serialize

@coderabbitai

This comment was marked as off-topic.

Mocking a connection is also simplified with a fixture. Aditionally two more tests were added.
@surister surister self-assigned this Oct 14, 2025
@amotl
Copy link
Member

amotl commented Oct 16, 2025

Hi. Thanks for modernizing. We appreciate using testcontainers instead of testlayers and specifically to get rid of Zope-related packages from previous decades where maintenance seems to be fading. (see also GH-723, GH-725, GH-736)

However, is it possible to split project infrastructure / metadata updates vs. those test modernizations which will have a much larger impact to the testing codebase, and also possibly migrate test cases progressively? We otherwise fear the patch will become too big to review reasonably, a problem we've currently encountered elsewhere.

testcontainers/python-unittest demonstrates a way to use the modern testcontainers way of testing together with traditional Python unittest, intended to support this and other repositories on their modernization paths. Maybe this can help a bit on this occasion?

CrateDBTestAdapter is effectively just a little wrapper using the CrateDBContainer class that is implementing the testcontainers specification, so it can be slotted into unittest layer concepts, at least as an intermediate workaround adapter for supporting a progressive migration, when possible.

NB: In particular, zope-testing does not seem to cause problems (GH-738), so we could possibly afford to keep it for a while, while still migrating away from setup.py?

@surister
Copy link
Member Author

However, is it possible to split project infrastructure / metadata updates vs. those test modernizations which will have a much larger impact to the testing codebase, and also possibly migrate test cases progressively? We otherwise fear the patch will become too big to review reasonably, a problem we've currently encountered elsewhere.

Yes I can split the PR into -> metadata & tests. I put them together because reviewing a setup.py -> pyproject.toml migration is trivial for us, since we are all well accustomed to a pyproject.toml definition. So it felt that it wouldn't make the review easier.

testcontainers/python-unittest demonstrates a way to use the modern testcontainers way of testing together with traditional Python unittest, intended to support this and other repositories on their modernization paths. Maybe this can help a bit on this occasion?

My goal is to move to the current python standard which is to use pytest, moving the Testlayer -> unittest testcontainers -> pytest testcontainers is not something I want to do, since moving to pytest is very straight forward

NB: In particular, zope-testing does not seem to cause problems (#738), so we could possibly afford to keep it for a while, while still migrating away from setup.py?

I kind of find it annoying, with just pytest every test need is pretty much solved, I don't think there is any need for it nowadays, migrating away from zope-testing is part of the unittest -> pytest story.

I understand that the review could be a bit painful but I think it's one of those that happen every few years that you just have to do it, I think that we are all very used to pytest and as you can see in the ones that I migrated, the resulting code is very light and shorter than the unitests', so I'd ask for a little bit of help soldiering here 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants