Courseiva
Design and implement build and release pipelinesmediumMultiple ChoiceObjective-mapped

AZ-400 Practice Question: Design and implement build and release pipelines

Your team uses GitHub Actions to build a Python application. The workflow includes a step to run unit tests with pytest. The tests pass locally but fail in CI with 'ModuleNotFoundError: No module named 'myapp''. The repository structure has the application code in a subdirectory 'src/'. What is the most likely fix?

⚠ Common exam trap

Candidates often confuse changing the working directory (Option A) with modifying the module search path, not realizing that Python's import resolution depends on sys.path, not the current working directory.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Set the environment variable PYTHONPATH to 'src/' before running tests.

The Python interpreter cannot find the 'myapp' module when tests run in CI, even though the code is present in the 'src/' subdirectory. Setting PYTHONPATH to 'src/' tells Python to include that directory in the module search path, allowing 'import myapp' to resolve correctly without moving or copying files. This is the most direct fix for a missing module path issue in a CI environment where the working directory is not automatically set to the source folder.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Set the working directory of the test step to 'src/'.

    Why it's wrong here

    Changing the working directory to 'src/' only affects relative file paths, not Python's module search path. Python's import system relies on sys.path (built from PYTHONPATH, site-packages, and the script directory), so simply cd'ing into src/ does not make the src directory importable when running tests from a different location, and the ModuleNotFoundError would persist.

  • Add a step to install dependencies with 'pip install -r requirements.txt'.

    Why it's wrong here

    Running 'pip install -r requirements.txt' installs third-party dependencies listed in the requirements file, but it does not install or expose the local package located in 'src/'. Since the existing note states dependencies are already installed, this step would be redundant and would not fix an import error for the project's own source package.

  • Set the environment variable PYTHONPATH to 'src/' before running tests.

    Why this is correct

    Setting PYTHONPATH to 'src/' before running tests adds the 'src' directory to Python's module search path, allowing the test runner to import the local package modules directly. This is a standard and effective fix for a src-layout project where the package has not been installed, directly resolving the ModuleNotFoundError.

  • Add a step to run 'pip install -e .' from the repository root.

    Why it's wrong here

    Running 'pip install -e .' from the repository root requires a setup.py, setup.cfg, or pyproject.toml at the root that defines the package and its location (e.g., using setuptools with package-dir pointing to 'src'). Without such a configuration, pip will fail to build the project, and even if it succeeded, it would not necessarily resolve imports unless the package configuration explicitly maps the src directory.

Visual reference

Client Recursive Resolver Root DNS (13 root servers) TLD DNS (.com, .org, …) Authoritative example.com query IP addr answer

About these practice questions

Courseiva writes every AZ-400 question from scratch — 823 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This AZ-400 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AZ-400 exam.