labthings / labthings/labthings-fastapi

Unit tests using `r` as a variable name are shaddowed by PDB commands

Open
#223 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
9
Forks
4
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
Most code that uses TestClient gets a response from the server as r = client.get(...) [or similar for post requests. However, if we use pytests --pdb flag to drop into the terminal, it is impossible to read this value as r is one of the many single letter PDB commands.

It can be reassigned, but by this time you have accidentally returned as this is what r means in PDB

This is an easy fix, and will improve variable naming and test readability at the same time.

To Reproduce
Make a TestClient unit test fail with the --pdb flag. Try to read r by typing r. You will be returned out of PDB

Expected behaviour
The response should print.

System:

  • OS: Kubuntu 24.04
  • Python version: 3.11
  • Version: 0.0.12

Additional context
Add any other context about the problem here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the TestClient unit tests that assign responses to r, then reproduce the issue using the --pdb flag and a failing test. Rename the affected response variables so entering r in PDB no longer exits the debugger, and verify the unit tests still pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
fastapi, python
Domain
testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.