testcontainers / testcontainers-python

Testcontainers is a Python library that providing a friendly API to run Docker container. It is designed to create runtime environment to use during your automatic tests.
https://testcontainers-python.readthedocs.io/en/latest/
Apache License 2.0
1.51k stars 281 forks source link

Bug: Installation documentation is unclear #554

Closed menzenski closed 2 months ago

menzenski commented 4 months ago

Describe the bug

I'm new to testcontainers and have been working on getting it set up to run MongoDB tests in Python.

I found https://testcontainers.com/guides/getting-started-with-testcontainers-for-python/ which instructs to install testcontainers-postgres, so I searched PyPi for testcontainers-mongo, found https://pypi.org/project/testcontainers-mongodb/, installed it (specifically with poetry add --group dev testcontainers-mongod, which installed v0.0.1rc1), and started using it to write tests.

I then ran into errors when trying to set the username, password, and dbname kwargs, which the documentation says I should be able to set:

class MongoDbContainer(image: str = 'mongo:latest', port: int = 27017, username: str | None = None, password: str | None = None, dbname: str | None = None, **kwargs)

In searching around for a resolution to this issue I realized that testcontainers in PyPi was published just last week with v4.4.0, while testcontainers-mongodb (and other packages like testcontainers-postgres) have not been published to PyPi since January 2023, and are only v0.0.1rc1.

I looked up this GitHub repository, saw the mongodb extra, and then removed the testcontainers-mongodb I had installed previously, and installed testcontainers[mongodb] instead.

This resolved my issue in that I am now able to set the username, password, and dbname kwargs that I wanted to. But I wanted to log an issue here to raise a request for some clarity around the best way to install testcontainers for Python.

I'm happy to contribute some draft documentation but may need some direction on where/how that should be done.

alexanderankin commented 4 months ago

opened a PR to fix this: https://github.com/testcontainers/tc-guide-getting-started-with-testcontainers-for-python/pull/3

alexanderankin commented 2 months ago

the pr was merged, if this comes up again, should probably be a separate issue