This document is a reference for common testing patterns in a Django/Python project using Pytest.
Contents:
This document is a reference for common testing patterns in a Django/Python project using Pytest.
Contents:
| #!/usr/bin/env bash | |
| # | |
| # Run pre-commit on every commit in your PR branch. | |
| # | |
| # The rebase will stop is pre-commit fails on any commit, allowing you to fix | |
| # the issues. Once you've made changes, verify that pre-commit now passes on | |
| # that commit with: | |
| # | |
| # pre-commit run --from HEAD^ --to HEAD | |
| # |
| #!/usr/bin/env bash | |
| # | |
| # Print a TSV of items that are accessible by a given user. | |
| set -e | |
| export OP_FORMAT=json | |
| function main() { |
| #!/usr/bin/env bash | |
| # | |
| # List a TSV of users who have access to an item. | |
| set -e | |
| export OP_FORMAT=json | |
| function main() { | |
| local item_id="$1" |
| #!/usr/bin/env bash | |
| # | |
| # Bootstrap script for setting up a new OSX machine | |
| # | |
| # This should be idempotent so it can be run multiple times. | |
| # | |
| # Some apps don't have a cask and so still need to be installed by hand. These | |
| # include: | |
| # | |
| # - Twitter (app store) |
| #!/usr/bin/env bash | |
| # | |
| # Check the status of a folder of repos to see if there are any unpushed commits. | |
| # | |
| # This is intended to help migrate to a new laptop, where you want to check | |
| # that there are no unpushed local commits before switching to the new machine. | |
| # | |
| # Needs `rg` and `fd` installed. | |
| set -e |
| #!/usr/bin/env bash | |
| # | |
| # A Bash script to run a TDD loop for building a Python module to pass tests. | |
| set -euo pipefail | |
| # How many times to loop. | |
| ATTEMPTS=4 | |
| # The system prompt to use when creating the initial version. |
| #!/usr/bin/env bash | |
| # | |
| # Get the value of a tag for a running EC2 instance. | |
| # | |
| # This can be useful within bootstrapping scripts ("user-data"). | |
| # | |
| # Note the EC3 instance needs to have an IAM role that lets it read tags. The policy | |
| # JSON for this looks like: | |
| # | |
| # { |
| #!/usr/bin/env bash | |
| # | |
| # Try and squash unstaged changes into existing branch commits. | |
| # | |
| # This command examines each unstaged file and attempts to create a fix-up | |
| # commit to squash it into its natural parent in the current branch. | |
| # | |
| # - If it's able to do this for all modified files, the fix-up files are | |
| # automatically squashed in. | |
| # |
| # Python start-up file | |
| # -------------------- | |
| # Ensure a PYTHONSTARTUP environment variable points to the location of this file. | |
| # See https://docs.python.org/3/using/cmdline.html#envvar-PYTHONSTARTUP | |
| # Always have pp available | |
| from pprint import pprint as pp | |
| # Pre-emptively import datetime as I use it a lot. | |
| import datetime |