Challenge - 5 Problems
PyTest GitHub Actions Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this GitHub Actions step running PyTest?
Given this GitHub Actions YAML snippet, what will be the output shown in the logs if all tests pass?
PyTest
steps:
- name: Run tests
run: pytest --maxfail=1 --disable-warnings -qAttempts:
2 left
💡 Hint
PyTest shows a summary line with passed, failed, and skipped tests.
✗ Incorrect
The command runs PyTest quietly with warnings disabled and stops after one failure. If all tests pass, the output summary shows '1 passed, 0 failed, 0 skipped'.
❓ Configuration
intermediate2:00remaining
Which GitHub Actions YAML snippet correctly installs dependencies and runs PyTest?
Select the YAML snippet that correctly installs Python dependencies from requirements.txt and runs PyTest in GitHub Actions.
Attempts:
2 left
💡 Hint
You need to set up Python 3.12 and install dependencies before running tests.
✗ Incorrect
Option D correctly checks out code, sets up Python 3.12, installs dependencies from requirements.txt, then runs PyTest. Other options miss installing dependencies or use wrong Python versions.
❓ Troubleshoot
advanced2:00remaining
Why does this GitHub Actions PyTest step fail with 'ModuleNotFoundError'?
You have this step in your workflow:
steps:
- uses: actions/checkout@v3
- name: Run tests
run: pytest
But the logs show 'ModuleNotFoundError: No module named mypackage'. What is the most likely cause?
Attempts:
2 left
💡 Hint
Check if dependencies are installed before running tests.
✗ Incorrect
Without installing dependencies, the Python environment lacks the required packages, causing ModuleNotFoundError. The checkout action succeeded since code is present, pytest command is valid, and pytest is usually pre-installed or installed with dependencies.
🔀 Workflow
advanced2:00remaining
What is the correct order of steps to run PyTest in GitHub Actions?
Arrange these steps in the correct order to run PyTest successfully in GitHub Actions:
Attempts:
2 left
💡 Hint
You must have code checked out before installing dependencies and running tests.
✗ Incorrect
First, checkout code (2), then setup Python (4), then install dependencies (1), finally run tests (3). Other orders break dependencies or run tests before setup.
✅ Best Practice
expert2:00remaining
Which GitHub Actions configuration best ensures test failures stop the workflow immediately?
You want your GitHub Actions workflow to stop running further steps if PyTest finds any failing tests. Which configuration achieves this?
Attempts:
2 left
💡 Hint
Look for an option that stops after the first failure.
✗ Incorrect
Option A uses --maxfail=1 to stop after one failure, causing the step to fail and stop the workflow. Option A ignores failures, option A continues despite collection errors, option A disables maxfail stopping.