~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to doc/developers/testing.txt

  • Committer: Martin von Gagern
  • Date: 2011-06-01 12:53:56 UTC
  • mto: This revision was merged to the branch mainline in revision 6009.
  • Revision ID: martin.vgagern@gmx.net-20110601125356-lwozv2vecea6hxfz
Change from no_decorate to classify as name for the argument.

The command line switch remains as --no-classify, to keep backwards
compatibility.  Users are free to include --no-classify in an alias, and
still use --classify to change back.

Show diffs side-by-side

added added

removed removed

Lines of Context:
745
745
        _test_needs_features = [features.apport]
746
746
 
747
747
 
748
 
Testing translations
749
 
-----------------------
750
 
 
751
 
Translations are disabled by default in tests.  If you want to test
752
 
that code is translated you can use the ``ZzzTranslations`` class from
753
 
``test_i18n``::
754
 
 
755
 
    self.overrideAttr(i18n, '_translations', ZzzTranslations())
756
 
 
757
 
And check the output strings look like ``u"zz\xe5{{output}}"``.
758
 
 
759
 
To test the gettext setup and usage you override i18n.installed back
760
 
to self.i18nInstalled and _translations to None, see
761
 
test_i18n.TestInstall.
762
 
 
763
 
 
764
748
Testing deprecated code
765
749
-----------------------
766
750
 
1034
1018
 
1035
1019
    self.overrideAttr(osutils, '_cached_user_encoding', 'latin-1')
1036
1020
 
1037
 
This should be used with discretion; sometimes it's better to make the
1038
 
underlying code more testable so that you don't need to rely on monkey
1039
 
patching.
1040
 
 
1041
 
 
1042
 
Observing calls to a function
1043
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1044
 
 
1045
 
Sometimes it's useful to observe how a function is called, typically when
1046
 
calling it has side effects but the side effects are not easy to observe
1047
 
from a test case.  For instance the function may be expensive and we want
1048
 
to assert it is not called too many times, or it has effects on the
1049
 
machine that are safe to run during a test but not easy to measure.  In
1050
 
these cases, you can use `recordCalls` which will monkey-patch in a
1051
 
wrapper that records when the function is called.
1052
 
 
1053
 
 
1054
1021
Temporarily changing environment variables
1055
1022
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1056
1023
 
1105
1072
 
1106
1073
    tc qdisc add dev lo root handle 1: prio
1107
1074
    tc qdisc add dev lo parent 1:3 handle 30: netem delay 500ms 
1108
 
    tc filter add dev lo protocol ip parent 1:0 prio 3 u32 match ip dport 4155 0xffff flowid 1:3 
1109
 
    tc filter add dev lo protocol ip parent 1:0 prio 3 u32 match ip sport 4155 0xffff flowid 1:3 
 
1075
    tc qdisc add dev lo parent 30:1 handle 40: prio
 
1076
    tc filter add dev lo protocol ip parent 1:0 prio 3 u32 match ip dport 4155 0xffff flowid 1:3 handle 800::800
 
1077
    tc filter add dev lo protocol ip parent 1:0 prio 3 u32 match ip sport 4155 0xffff flowid 1:3 handle 800::801
1110
1078
 
1111
1079
and to remove this::
1112
1080