This document is a reference for common testing patterns in a Django/Python project using Pytest.
Contents:
// To use this, create a new Apps Script project and paste this script in. | |
// https://developers.google.com/apps-script | |
function FetchReport() { | |
// Define a Gmail search query. | |
var searchQuery = "cluedo after:2022-01-01" | |
// Define a predicate that determines when to stop looping. | |
function shouldWeKeepLooping(thread) { |
#!/usr/bin/env python | |
# | |
# Script to wrap JSON front-matter in markdown files with `---` delimiters. | |
# | |
# This allows Prettier to be used on the markdown file (and it won't try and format the JSON front | |
# matter). | |
# | |
# I needed this to convert old Hugo markdown files that had JSON front-matter. | |
import os | |
import sys |
#!/bin/bash | |
# | |
# Script that opens the Github pull request search page filtered to show closed pull | |
# requests from the last week, from members of a specified set of users. | |
# | |
# This can be useful for team leads when writing progress reports. | |
# Config | |
# ------ |
This document is a reference for common testing patterns in a Django/Python project using Pytest.
Contents:
import datetime | |
import pytz | |
from django.utils import timezone | |
from dateutil import tz | |
# This test passes. | |
def test_pytz_vs_dateutil_timezones(): | |
timezone_name = "Europe/London" | |
# Start with a naive dt. |
# 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 |
#!/usr/bin/env bash | |
# | |
# Fetch diff stats for the current repo from the last year | |
# Get a commit SHA from a year ago | |
OLD_SHA=$(git log --since="365 days ago" --until="364 days ago" -1 --pretty=format:"%H") | |
NEW_SHA=$(git rev-parse HEAD) | |
# Number of lines then and now | |
OLD_LINES=$(git diff --stat `git hash-object -t tree /dev/null`..$OLD_SHA | awk '/files changed/ {print $4}') |
import re | |
import subprocess | |
import pytest | |
@pytest.mark.parametrize( | |
"subject, error_msg", | |
[ | |
("WIP: working on something", "is a WIP commit"), |
" ============= " VIMRC file for David Winterbottom (@codeinthehole) " =========== | |
" Inspiration {{{ | |
" ----------- | |
" Videos: | |
" - http://www.youtube.com/watch?v=aHm36-na4-4 | |
" | |
" Articles: | |
" | |
" - http://alexpounds.com/blog/2014/06/06/the-vimrc-antiques-roadshow |