// jQuery
$(document).ready(function() {
// code
})
noun ( pl. automata |-tə| or automatons ) — a moving mechanical device made in imitation of a human being.
- A machine that performs a function according to a predetermined set of coded instructions, esp. one capable of a range of programmed responses to different circumstances.
- A scripting infrastructure for project and system management.
What I propose below is a Behaviour (or Story) Driven Development domain-specific language for writing your tests in Python. This uses some tricks of how imports are done (via encoding) to dynamically translate the tests from the DSL into pure Python. Additional tricks are used to preserve the line numbers of errors, offer abbreviated asserts, and automatically pass local variables from parent to child scopes.
This is parallelizable for efficient test running, compiles to Python bytecode for efficiency, and follows the same style as doctests.
If you hate DSLs (hey, Python ain’t Ruby!) consider this to be a file-length docstring. If you don’t like doctests then consider this to be a template engine for tests. (Most modern template engines generate Python code…)
from Queue import Queue, Empty | |
from socket import (socket, error, AF_INET, SOCK_STREAM, SOCK_DGRAM, | |
SOL_SOCKET, SOL_TCP, SO_ERROR, TCP_NODELAY) | |
from errno import EINPROGRESS | |
from select import select | |
from threading import current_thread | |
from concurrent.futures import Future | |
from functools import partial | |
import sys | |
import os |
#!/usr/bin/env python | |
""" Test HTTP Server | |
This script starts a http server that will respond to HTTP requests | |
with a predefined response. | |
Usage: | |
./http_server.py --port=8080 --code=404 --content="Page not Found" |
This is now an actual repo:
# All units in usecs (µsec) comparing Python 2.7 | 3.7. | |
# Last updated: 2019-02-11 | |
# MacBook Pro (15-inch, 2016) | |
# macOS 10.14.3 | |
# 2.7 GHz Intel Core i7 | |
# 16 GB 2133 MHz LPDDR3 | |
python -m timeit "200 <= 250 < 300" # 0.0354 | 0.059 | |
python2.7 -m timeit "250 in xrange(200, 300)" # 1.25 |