[Python-ideas] hookable assertions - to support testing utilities and debugging

Wes Turner wes.turner at gmail.com
Thu Feb 19 22:54:29 CET 2015


On Thu, Feb 19, 2015 at 5:32 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
>
>
> * is testing code categorically different from production code?
> * if yes, should assert statements be handled differently in testing code?
>

assert statements are compiled out with -O (e.g. PYTHON_OPTIMIZE=2)

* https://docs.python.org/3/using/cmdline.html#cmdoption-OO

* self.assert statements are not compiled out
* nose decorated test cases are not compiled out



> * if yes, how should that difference be communicated to readers and to
> the interpreter?
>

It's such a frequent pattern. ([declarative] "literate programming" (with
objects))

* Is there a better tool than tests for teaching?

* https://github.com/taavi/ipython_nose adds an IPython magic command
(%nose)
  that collects test functions
  and test output w/ IPYNB JSON (-> HTML, PDF, XML) output
  (e.g. for use with https://pypi.python.org/pypi/runipy)

* Justifying multiple failures and assertions per test:
  "Delayed assert / multiple failures per test"
http://pythontesting.net/strategy/delayed-assert/

* (collecting / emitting / yielding (s, p, o) tuples from nested dicts with
inferred #URI/paths)

* The JSON-LD test suite uses EARL, an RDF schema
(instead of xUnit XML)

  * http://json-ld.org/test-suite/
  * http://json-ld.org/test-suite/reports/
  * http://www.w3.org/TR/EARL10-Schema/
    "Evaluation and Report Language (EARL) 1.0 Schema" (2011)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150219/5c2d0d7e/attachment.html>


More information about the Python-ideas mailing list