Skip to content

Commit 48ea7b8

Browse files
Update imports for readthedocs (#89)
* Add readthedocs.yml config. * Add requirements. * Add docs target. * Modify imports. * Simplify setup.
1 parent 56e6b88 commit 48ea7b8

File tree

6 files changed

+31
-8
lines changed

6 files changed

+31
-8
lines changed

.readthedocs.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# .readthedocs.yml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
# Build documentation in the docs/ directory with Sphinx
9+
sphinx:
10+
configuration: docs/conf.py
11+
12+
# Optionally build your docs in additional formats such as PDF and ePub
13+
formats: all
14+
15+
# Optionally set the version of Python and requirements required to build your docs
16+
python:
17+
version: 3.7
18+
install:
19+
- method: pip
20+
path: .

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ REQUIREMENTS = $(addprefix requirements/,${PYTHON_VERSIONS:=.txt})
33
TESTS = $(addprefix tests/,${PYTHON_VERSIONS})
44
IMAGES = $(addprefix image/,${PYTHON_VERSIONS})
55
RUN = docker run --rm -it
6+
.PHONY : docs
67

78
# Default target
89

@@ -34,3 +35,8 @@ tests : ${TESTS}
3435
${TESTS} : tests/% : image/%
3536
${RUN} -v /var/run/docker.sock:/var/run/docker.sock testcontainers-python:$* bash -c \
3637
"flake8 && pytest -v ${ARGS}"
38+
39+
# Target to build the documentation
40+
41+
docs :
42+
sphinx-build -nW docs docs/_build/html

docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ help:
1717
# Catch-all target: route all unknown targets to Sphinx using the new
1818
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
1919
%: Makefile
20-
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

testcontainers/core/generic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1111
# License for the specific language governing permissions and limitations
1212
# under the License.
13-
import sqlalchemy
1413

1514
from testcontainers.core.container import DockerContainer
1615
from testcontainers.core.waiting_utils import wait_container_is_ready
@@ -23,6 +22,7 @@ def __init__(self, image):
2322

2423
@wait_container_is_ready()
2524
def _connect(self):
25+
import sqlalchemy
2626
engine = sqlalchemy.create_engine(self.get_connection_url())
2727
engine.connect()
2828

testcontainers/mongodb.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
# under the License.
1313
import os
1414

15-
from pymongo import MongoClient
16-
1715
from testcontainers.core.generic import DockerContainer
1816

1917

@@ -68,5 +66,6 @@ def get_connection_url(self):
6866
return "mongodb://{}:{}".format(self.get_container_host_ip(), port)
6967

7068
def get_connection_client(self):
69+
from pymongo import MongoClient
7170
return MongoClient("mongodb://{}:{}".format(self.get_container_host_ip(),
7271
self.get_exposed_port(self.port_to_expose)))

testcontainers/selenium.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
Allows to spin up selenium containers for testing with browsers.
1818
"""
1919

20-
from selenium import webdriver
21-
from selenium.webdriver.remote.webdriver import WebDriver
22-
2320
from testcontainers.core.container import DockerContainer
2421
from testcontainers.core.waiting_utils import wait_container_is_ready
2522

@@ -65,11 +62,12 @@ def _configure(self):
6562

6663
@wait_container_is_ready()
6764
def _connect(self):
65+
from selenium import webdriver
6866
return webdriver.Remote(
6967
command_executor=(self.get_connection_url()),
7068
desired_capabilities=self.capabilities)
7169

72-
def get_driver(self) -> WebDriver:
70+
def get_driver(self):
7371
return self._connect()
7472

7573
def get_connection_url(self) -> str:

0 commit comments

Comments
 (0)