From 22c4f271e8d3f9d9e8b377838d885e4f65c7e356 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Fri, 10 Aug 2018 15:57:44 -0700 Subject: small software tweaks --- software/python.page | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'software/python.page') diff --git a/software/python.page b/software/python.page index deada7a..0fd2531 100644 --- a/software/python.page +++ b/software/python.page @@ -102,15 +102,21 @@ number (as an int). RunSnakeRun ------------- +Runsnake seems to be unmaintained... `snakeviz` is the new thing? + Example session:: $ python -m cProfile -o ./dump.profile myscript.py --script-option blah $ # run to completion or Ctrl-C, then $ runsnakerun ./dump.profile + # or + $ snakeviz ./dump.profile nosetests ------------- +NOTE: by default I now use pytest instead of nose + To do minimal tests without wrapping everything in a class, import assert functions from nose.tools, eg:: @@ -169,3 +175,33 @@ To make Python 3.4 the default for `python` system-wide, do something like: For an individual user you can also just create a `python` alias. See also: http://linuxconfig.org/how-to-change-from-default-to-alternative-python-version-on-debian-linux + + +Nice Packages +-------------- + +subprocess/pexpect: https://github.com/kennethreitz/delegator.py + +time/datetime: https://github.com/crsmithdev/arrow + +tsv: https://github.com/kennethreitz/tablib + +simple HTML scraping: https://github.com/michaelhelmick/lassie + +sqlite3dbm is a library to back a python dict with sqlite3 on disk + + +pytest +----------- + +pytest sort of "just works" if you put test files under `./tests/`. If you want +crude file imports, skipping directories, and including `test_*` functions from +any python file (not just those with `test_*.py`, install `pytest-pythonpath` +and create a `pytest.ini` like: + + [pytest] + python_paths = . + python_files = *.py + norecursedirs = .svn _build tmp* + +Need to mock? -- cgit v1.2.3