Skip to content

Commit 16f6ca4

Browse files
authored
fix: update test module import (#623)
Following #612, updated the test module import with a better name and some minor fixes.
1 parent 0b866ff commit 16f6ca4

File tree

7 files changed

+17
-19
lines changed

7 files changed

+17
-19
lines changed

modules/test_module_import/README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.. autoclass:: testcontainers.test_module_import.NewSubModuleContainer
2+
.. title:: testcontainers.test_module_import.NewSubModuleContainer

modules/testmoduleimport/testcontainers/testmoduleimport/new_sub_module.py renamed to modules/test_module_import/testcontainers/test_module_import/new_sub_module.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ class NewSubModuleContainer(ServerContainer):
99
1010
>>> import httpx
1111
>>> from testcontainers.core.image import DockerImage
12-
>>> from testcontainers.testmoduleimport import NewSubModuleContainer
12+
>>> from testcontainers.test_module_import import NewSubModuleContainer
1313
14-
>>> with DockerImage(path="./modules/generic/tests/samples/python_server", tag="test-mod:latest") as image:
15-
... with NewSubModuleContainer(port=9000, image=image) as srv:
16-
... url = srv._create_connection_url()
14+
>>> with DockerImage(path="./modules/generic/tests/samples/python_server", tag="test-new-mod:latest") as image:
15+
... with NewSubModuleContainer(port=9000, image=image) as new_mod:
16+
... url = new_mod._create_connection_url()
1717
... response = httpx.get(f"{url}", timeout=5)
1818
... assert response.status_code == 200, "Response status code is not 200"
19-
... assert srv.print_mock() == "NewSubModuleContainer"
19+
... assert new_mod.additional_capability() == "NewSubModuleContainer"
2020
2121
"""
2222

2323
def __init__(self, port: int, image: str) -> None:
2424
super().__init__(port, image)
2525

26-
def print_mock(self) -> str:
26+
def additional_capability(self) -> str:
2727
return "NewSubModuleContainer"

modules/testmoduleimport/tests/test_mock_one.py renamed to modules/test_module_import/tests/test_mock_one.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33
from testcontainers.core.waiting_utils import wait_for_logs
44
from testcontainers.core.image import DockerImage
5-
from testcontainers.testmoduleimport import NewSubModuleContainer
5+
from testcontainers.test_module_import import NewSubModuleContainer
66

77

88
def test_like_doctest():
9-
with DockerImage(path="./modules/generic/tests/samples/python_server", tag="test-srv:latest") as image:
10-
with NewSubModuleContainer(port=9000, image=image) as srv:
11-
assert srv.print_mock() == "NewSubModuleContainer"
12-
url = srv._create_connection_url()
9+
with DockerImage(path="./modules/generic/tests/samples/python_server", tag="test-new-mod:latest") as image:
10+
with NewSubModuleContainer(port=9000, image=image) as new_mod:
11+
url = new_mod._create_connection_url()
1312
response = httpx.get(f"{url}", timeout=5)
1413
assert response.status_code == 200, "Response status code is not 200"
15-
_ = wait_for_logs(srv, "GET / HTTP/1.1")
14+
assert new_mod.additional_capability() == "NewSubModuleContainer"

modules/testmoduleimport/README.rst

Lines changed: 0 additions & 2 deletions
This file was deleted.

poetry.lock

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ packages = [
3737
{ include = "testcontainers", from = "modules/cosmosdb" },
3838
{ include = "testcontainers", from = "modules/elasticsearch" },
3939
{ include = "testcontainers", from = "modules/generic" },
40-
{ include = "testcontainers", from = "modules/testmoduleimport"},
40+
{ include = "testcontainers", from = "modules/test_module_import"},
4141
{ include = "testcontainers", from = "modules/google" },
4242
{ include = "testcontainers", from = "modules/influxdb" },
4343
{ include = "testcontainers", from = "modules/k3s" },
@@ -120,7 +120,7 @@ cosmosdb = ["azure-cosmos"]
120120
cockroachdb = []
121121
elasticsearch = []
122122
generic = ["httpx"]
123-
testmoduleimport = ["httpx"]
123+
test_module_import = ["httpx"]
124124
google = ["google-cloud-pubsub", "google-cloud-datastore"]
125125
influxdb = ["influxdb", "influxdb-client"]
126126
k3s = ["kubernetes", "pyyaml"]

0 commit comments

Comments
 (0)