0
0
PyTesttesting~10 mins

Docker-based test execution in PyTest - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to run pytest inside a Docker container using the correct command.

PyTest
docker run --rm -v $(pwd):/app -w /app python:3.12 [1]
Drag options to blanks, or click blank then click option'
Abash
Bpython
Cpip install pytest
Dpytest
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'python' instead of 'pytest' to run tests.
Trying to install pytest instead of running it.
2fill in blank
medium

Complete the code to mount the current directory into the Docker container for test access.

PyTest
docker run --rm -v [1]:/app -w /app python:3.12 pytest
Drag options to blanks, or click blank then click option'
A/usr/src/app
B$(pwd)
C/home/user
D/tmp
Attempts:
3 left
💡 Hint
Common Mistakes
Using a fixed path instead of the current directory.
Not mounting the directory, so tests can't find the code.
3fill in blank
hard

Fix the error in the Docker command to ensure the working directory is set correctly for pytest.

PyTest
docker run --rm -v $(pwd):/app -w [1] python:3.12 pytest
Drag options to blanks, or click blank then click option'
A/app
B/home/app
C/usr/src/app
D/root
Attempts:
3 left
💡 Hint
Common Mistakes
Setting working directory to a path not matching the mounted volume.
Using default working directory which may not contain the tests.
4fill in blank
hard

Fill both blanks to create a Docker command that installs pytest and runs tests inside the container.

PyTest
docker run --rm -v $(pwd):/app -w /app python:3.12 bash -c "[1] && [2]"
Drag options to blanks, or click blank then click option'
Apip install pytest
Bpytest
Cpython test.py
Dapt-get update
Attempts:
3 left
💡 Hint
Common Mistakes
Running tests without installing pytest first.
Using wrong test command like 'python test.py' instead of 'pytest'.
5fill in blank
hard

Fill all three blanks to define a Docker Compose service that runs pytest with mounted volume and working directory.

PyTest
services:
  test:
    image: python:3.12
    volumes:
      - [1]:/app
    working_dir: [2]
    command: [3]
Drag options to blanks, or click blank then click option'
A.
B/app
Cpytest
D/usr/src/app
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong mount path or working directory.
Forgetting to set the command to 'pytest'.