Skip to main content

Practice debugging, by intentionally introducing bugs into an existing codebase.

Project description

py-bugger

When people learn debugging, they typically have to learn it by focusing on whatever bugs come up in their code. They don't get to work on specific kinds of errors, and they don't get the chance to progress from simple to more complex bugs. This is quite different from how we teach and learn just about any other skill.

py-bugger lets you intentionally introduce specific kinds and numbers of bugs to a working project. You can introduce bugs to a project with a single file, or a much larger project. This is much different from the typical process of waiting for your next bug to show up, or introducing a bug yourself. py-bugger gives people a structured way to learn debugging, just as we approach all other areas of programming.

Example usage

py-bugger acts on directories, so consider a directory with just one file, name_picker.py. It chooses a single name from a list of names, and announces the winner:

$ python name_picker.py
The winner: Willie!

To practice debugging, we'll introduce a ModuleNotFoundError:

$ pip install https://github.com/ehmatthes/py-bugger.git
$ py-bugger --exception-type ModuleNotFoundError
Introducing a ModuleNotFoundError...
  Modified file.

Now, run the project again and you should see it fail:

$ python name_picker.py
Traceback (most recent call last):
  File "name_picker.py", line 1, in <module>
    import rando
ModuleNotFoundError: No module named 'rando'

You can open your file, and practice debugging. If you get the project working again, great!

If you get stuck, all the bugs that were introduced are contained in a single Git commit. You can see those bugs using git diff.

Current state

This project is a proof of concept at the moment; I'm releasing it at this stage to get feedback about whether it's a useful tool. It should work on all OSes, but it only introduces one kind of bug. If there's any interest at all in this project, I'll quickly bring it to a more usable state.

Usage:

$ py-bugger --help
usage: py-bugger [-h] [-e EXCEPTION_TYPE] [--target-dir TARGET_DIR]

Practice debugging, by intentionally introducing bugs into an existing codebase.

options:
  -h, --help            show this help message and exit
  -e EXCEPTION_TYPE, --exception-type EXCEPTION_TYPE
                        What kind of exception to induce.
  --target-dir TARGET_DIR
                        What code directory to target. (Be careful when using this arg!)

Trying py-bugger

If you're interested in trying the project at this early stage, do the following:

  • Make a new directory with a single .py file in it.
  • Make sure the .py file has at least one import statement.
  • Run your file, and make sure it works.
  • Make an initial Git commit.
  • Install py-bugger.
  • Run py-bugger -e ModuleNotFoundError.
  • Run your project, and see if it generates a ModuleNotFoundError exception.

Brief Roadmap

If this project is useful or interesting to people, here's a brief roadmap of where I'm planning to take it:

  • Check for a clean Git state before introducing any bugs.
  • Make a new commit after introducing bugs.
  • Clarify usage docs, so people only introduce bugs where they want them to be.
  • Expand the variety of exception types that can be introduced.
  • Expand the variety of possible causes for inducing specific exceptions.
  • Visit all files not in .gitignore, and not in a tests/ dir.
  • Generate logical (non-crashing) errors as well as specific exception types.
  • Expand usage to allow an arbitrary number and kind of bugs.
  • Develop a list of good projects to practice against. ie, clone from GitHub, run its tests, run py-bugger, and practice debugging.

Contributing

If you're interested in this project, please feel free to get in touch. If you have general feedback or just want to see the project progress, please share your thoughts in the Initial feedback discussion. Also, feel free to open a new issue.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_bugger-0.1.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_bugger-0.1.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file python_bugger-0.1.0.tar.gz.

File metadata

  • Download URL: python_bugger-0.1.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for python_bugger-0.1.0.tar.gz
Algorithm Hash digest
SHA256 22e3547f57ddcef750c41da1d722d6c770ae98ab00515cd9c6d093328bd8c4b5
MD5 4b80d852b51918f96fad7f5b59669c3b
BLAKE2b-256 3b9e4b78d31e31a431b623b3cc776edd6a6780aad4e0c0246e09e482c6ee4ec6

See more details on using hashes here.

File details

Details for the file python_bugger-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: python_bugger-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for python_bugger-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 961b4f34c80b0d1e6d4454383dbccf3276805cfff4b200b01781c71ea6ab35d9
MD5 c349701d56f89f24c982180f2a1221b4
BLAKE2b-256 65d146996dbbac35c5da16ef1ab7b9ed4dbbb4cb7f74dfece60260db5ed4a74b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page