~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to doc/developers/testing.txt

  • Committer: Jelmer Vernooij
  • Date: 2011-08-04 13:30:30 UTC
  • mfrom: (6050 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6052.
  • Revision ID: jelmer@samba.org-20110804133030-uwo00unp8b0n782c
merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
516
516
regress.
517
517
 
518
518
This is done by running the command in a subprocess with
519
 
``--profile-imports``.  Starting a whole Python interpreter is pretty
520
 
slow, so we don't want exhaustive testing here, but just enough to guard
521
 
against distinct fixed problems.
 
519
``PYTHON_VERBOSE=1``.  Starting a whole Python interpreter is pretty slow,
 
520
so we don't want exhaustive testing here, but just enough to guard against
 
521
distinct fixed problems.
522
522
 
523
523
Assertions about precisely what is loaded tend to be brittle so we instead
524
524
make assertions that particular things aren't loaded.
1018
1018
 
1019
1019
    self.overrideAttr(osutils, '_cached_user_encoding', 'latin-1')
1020
1020
 
 
1021
This should be used with discretion; sometimes it's better to make the
 
1022
underlying code more testable so that you don't need to rely on monkey
 
1023
patching.
 
1024
 
 
1025
 
 
1026
Observing calls to a function
 
1027
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
1028
 
 
1029
Sometimes it's useful to observe how a function is called, typically when
 
1030
calling it has side effects but the side effects are not easy to observe
 
1031
from a test case.  For instance the function may be expensive and we want
 
1032
to assert it is not called too many times, or it has effects on the
 
1033
machine that are safe to run during a test but not easy to measure.  In
 
1034
these cases, you can use `recordCalls` which will monkey-patch in a
 
1035
wrapper that records when the function is called.
 
1036
 
 
1037
 
1021
1038
Temporarily changing environment variables
1022
1039
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1023
1040