-
Notifications
You must be signed in to change notification settings - Fork 313
fix: pass doctests, s/doctest/doctests/, run them in gha, s/asyncpg/psycopg/ in doctest, fix keycloak flakiness: wait for first user #505
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Doctests are run as interpreted code, where usage of await is only allowed inside async functions. By replacing the async code with a sync equivalent, doctests should run nicely for the INDEX.rst once again.
Doctests/usage examples have been written in a wide variety of ways, some using the latest tag on Docker images and some not testing any output from the usage examples. This is a first step towards having repeatable tests with pinned versions and output-checking doctests.
kiview
approved these changes
Mar 27, 2024
alexanderankin
approved these changes
Mar 27, 2024
bearrito
pushed a commit
to bearrito/testcontainers-python
that referenced
this pull request
Mar 30, 2024
…sycopg/ in doctest, fix keycloak flakiness: wait for first user (testcontainers#505) Doctests are run as interpreted code from docstrings. In order to run these tests, libraries need to be available for the example code, and usage of async code either needs to be wrapped in an `asyncio` call or avoided completely. This PR fixes up all failing doctests and makes `make doctests` target run successfully again. Summary: - Renames Make target `doctest` to `doctests` to follow naming convention from `tests` target - Adds `doctests` step to Github Action workflow runs - Replaces `asyncpg` example from `index.rst` with `psycopg` to be able to run as a doctest. Also added `psycopg` as dev dependency (`asyncpg` was already missing from here) - Fixes Keycloak doctest by providing expected output, also did the same for regular test - Also: Fixed `wait_for_container` method in `Keycloak` module to actually wait for the first user to be created (in order to be able to authenticate at all) before returning the started container, if the command is `dev-start`. This is needed in order to prevent race conditions in flaky tests and for the sample usage code.
alexanderankin
pushed a commit
that referenced
this pull request
Apr 1, 2024
🤖 I have created a release *beep* *boop* --- ## [4.3.0](testcontainers-v4.2.0...testcontainers-v4.3.0) (2024-04-01) ### Features * **client:** Add custom User-Agent in Docker client as `tc-python/<version>` ([#507](#507)) ([dd55082](dd55082)) ### Bug Fixes * Add CassandraContainer ([#476](#476)) ([507e466](507e466)) * add chroma container ([#515](#515)) ([0729bf4](0729bf4)) * Add Weaviate module ([#492](#492)) ([90762e8](90762e8)) * **cassandra:** make cassandra dependency optional/test-only ([#518](#518)) ([bddbaeb](bddbaeb)) * **core:** allow setting docker command path for docker compose ([#512](#512)) ([63fcd52](63fcd52)) * **google:** add support for Datastore emulator ([#508](#508)) ([3d891a5](3d891a5)) * Improved Oracle DB module ([#363](#363)) ([6e6d8e3](6e6d8e3)) * inconsistent test runs for community modules ([#497](#497)) ([914f1e5](914f1e5)) * **kafka:** Add redpanda testcontainer module ([#441](#441)) ([451d278](451d278)) * **kafka:** wait_for_logs in kafka container to reduce lib requirement ([#377](#377)) ([909107b](909107b)) * **keycloak:** container should use dedicated API endpoints to determine container readiness ([#490](#490)) ([2e27225](2e27225)) * **nats:** Client-Free(ish) NATS container ([#462](#462)) ([302c73d](302c73d)) * **new:** add a new Docker Registry test container ([#389](#389)) ([0f554fb](0f554fb)) * pass doctests, s/doctest/doctests/, run them in gha, s/asyncpg/psycopg/ in doctest, fix keycloak flakiness: wait for first user ([#505](#505)) ([545240d](545240d)) * pass updated keyword args to Publisher/Subscriber client in google/pubsub [#161](#161) ([#164](#164)) ([8addc11](8addc11)) * Qdrant module ([#463](#463)) ([e8876f4](e8876f4)) * remove accidentally added pip in dev dependencies ([#516](#516)) ([dee20a7](dee20a7)) * **ryuk:** Enable Ryuk test suite. Ryuk image 0.5.1 -> 0.7.0. Add RYUK_RECONNECTION_TIMEOUT env variable ([#509](#509)) ([472b2c2](472b2c2)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Doctests are run as interpreted code from docstrings. In order to run these tests, libraries need to be available for the example code, and usage of async code either needs to be wrapped in an
asyncio
call or avoided completely.This PR fixes up all failing doctests and makes
make doctests
target run successfully again.Summary:
doctest
todoctests
to follow naming convention fromtests
targetdoctests
step to Github Action workflow runsasyncpg
example fromindex.rst
withpsycopg
to be able to run as a doctest. Also addedpsycopg
as dev dependency (asyncpg
was already missing from here)wait_for_container
method inKeycloak
module to actually wait for the first user to be created (in order to be able to authenticate at all) before returning the started container, if the command isdev-start
. This is needed in order to prevent race conditions in flaky tests and for the sample usage code.