Bird
0
0

You want to run tests inside a container but only for Python files changed in your Git branch. Which approach is best?

hard📝 Workflow Q9 of 15
Docker - in CI/CD
You want to run tests inside a container but only for Python files changed in your Git branch. Which approach is best?
AManually copy changed files into container before testing
BRun pytest on all files inside container ignoring Git changes
CRun tests outside container only on changed files
DUse a script to list changed files, then run pytest on those inside the container
Step-by-Step Solution
Solution:
  1. Step 1: Identify selective testing method

    Listing changed files via Git and passing them to pytest inside container runs only needed tests.
  2. Step 2: Evaluate other options

    Running all tests wastes time, manual copying is error-prone, and running outside container loses environment consistency.
  3. Final Answer:

    Use a script to list changed files, then run pytest on those inside the container -> Option D
  4. Quick Check:

    Selective testing = script + container pytest [OK]
Quick Trick: Filter changed files with Git, then run tests inside container [OK]
Common Mistakes:
  • Testing all files unnecessarily
  • Copying files manually instead of mounting
  • Running tests outside container losing environment

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes