0
0
PyTesttesting~20 mins

Running PyTest in GitHub Actions - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
PyTest GitHub Actions Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2: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 -q
AAll tests skipped
B1 passed, 0 failed, 0 skipped
CSyntaxError: invalid syntax
DNo tests collected
Attempts:
2 left
💡 Hint
PyTest shows a summary line with passed, failed, and skipped tests.
Configuration
intermediate
2: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.
A
steps:
  - uses: actions/checkout@v3
  - name: Install dependencies
    run: pip install pytest
  - name: Run tests
    run: pytest
B
steps:
  - uses: actions/checkout@v3
  - name: Setup Python
    uses: actions/setup-python@v4
    with:
      python-version: '3.12'
  - name: Run tests
    run: pytest
C
steps:
  - uses: actions/checkout@v3
  - name: Setup Python
    uses: actions/setup-python@v2
    with:
      python-version: '2.7'
  - name: Run tests
    run: pytest
D
steps:
  - uses: actions/checkout@v3
  - name: Setup Python
    uses: actions/setup-python@v4
    with:
      python-version: '3.12'
  - name: Install dependencies
    run: pip install -r requirements.txt
  - name: Run tests
    run: pytest
Attempts:
2 left
💡 Hint
You need to set up Python 3.12 and install dependencies before running tests.
Troubleshoot
advanced
2: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?
APyTest is not installed in the runner environment.
BThe checkout action failed to download the code.
CThe Python environment is missing the package dependencies because pip install was not run.
DThe pytest command syntax is incorrect.
Attempts:
2 left
💡 Hint
Check if dependencies are installed before running tests.
🔀 Workflow
advanced
2: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:
A2,4,1,3
B4,2,1,3
C2,1,4,3
D1,2,4,3
Attempts:
2 left
💡 Hint
You must have code checked out before installing dependencies and running tests.
Best Practice
expert
2: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?
Arun: pytest --maxfail=1 --disable-warnings -q
Brun: pytest --continue-on-collection-errors
Crun: pytest || true
Drun: pytest --maxfail=0
Attempts:
2 left
💡 Hint
Look for an option that stops after the first failure.