/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Martin von Gagern
  • Date: 2010-05-02 20:10:25 UTC
  • mto: This revision was merged to the branch mainline in revision 5203.
  • Revision ID: martin.vgagern@gmx.net-20100502201025-ssuldxi8i98desfh
Added blackbox tests for --directory option.

Added tests for the new --directory (-d) option to these commands: added,
annotate, bind, cat, clean-tree, deleted, export, ignore, ignored,
lookup-revision, ls, modified, nick, re-sign, unbind, unknowns.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
"""Testing framework extensions"""
18
17
 
19
18
# TODO: Perhaps there should be an API to find out if bzr running under the
20
19
# test suite -- some plugins might want to avoid making intrusive changes if
112
111
from bzrlib.tests import (
113
112
    test_server,
114
113
    TestUtil,
115
 
    treeshape,
116
114
    )
117
115
from bzrlib.tests.http_server import HttpServer
118
116
from bzrlib.tests.TestUtil import (
119
117
                          TestSuite,
120
118
                          TestLoader,
121
119
                          )
 
120
from bzrlib.tests.treeshape import build_tree_contents
122
121
from bzrlib.ui import NullProgressView
123
122
from bzrlib.ui.text import TextUIFactory
124
123
import bzrlib.version_info_formats.format_custom
1313
1312
            f.close()
1314
1313
        self.assertEqualDiff(content, s)
1315
1314
 
1316
 
    def assertDocstring(self, expected_docstring, obj):
1317
 
        """Fail if obj does not have expected_docstring"""
1318
 
        if __doc__ is None:
1319
 
            # With -OO the docstring should be None instead
1320
 
            self.assertIs(obj.__doc__, None)
1321
 
        else:
1322
 
            self.assertEqual(expected_docstring, obj.__doc__)
1323
 
 
1324
1315
    def failUnlessExists(self, path):
1325
1316
        """Fail unless path or paths, which may be abs or relative, exist."""
1326
1317
        if not isinstance(path, basestring):
1524
1515
            'EDITOR': None,
1525
1516
            'BZR_EMAIL': None,
1526
1517
            'BZREMAIL': None, # may still be present in the environment
1527
 
            'EMAIL': 'jrandom@example.com', # set EMAIL as bzr does not guess
 
1518
            'EMAIL': None,
1528
1519
            'BZR_PROGRESS_BAR': None,
1529
1520
            'BZR_LOG': None,
1530
1521
            'BZR_PLUGIN_PATH': None,
2578
2569
                content = "contents of %s%s" % (name.encode('utf-8'), end)
2579
2570
                transport.put_bytes_non_atomic(urlutils.escape(name), content)
2580
2571
 
2581
 
    build_tree_contents = staticmethod(treeshape.build_tree_contents)
 
2572
    def build_tree_contents(self, shape):
 
2573
        build_tree_contents(shape)
2582
2574
 
2583
2575
    def assertInWorkingTree(self, path, root_path='.', tree=None):
2584
2576
        """Assert whether path or paths are in the WorkingTree"""
3200
3192
    return result
3201
3193
 
3202
3194
 
3203
 
def workaround_zealous_crypto_random():
3204
 
    """Crypto.Random want to help us being secure, but we don't care here.
3205
 
 
3206
 
    This workaround some test failure related to the sftp server. Once paramiko
3207
 
    stop using the controversial API in Crypto.Random, we may get rid of it.
3208
 
    """
3209
 
    try:
3210
 
        from Crypto.Random import atfork
3211
 
        atfork()
3212
 
    except ImportError:
3213
 
        pass
3214
 
 
3215
 
 
3216
3195
def fork_for_tests(suite):
3217
3196
    """Take suite and start up one runner per CPU by forking()
3218
3197
 
3242
3221
        c2pread, c2pwrite = os.pipe()
3243
3222
        pid = os.fork()
3244
3223
        if pid == 0:
3245
 
            workaround_zealous_crypto_random()
3246
3224
            try:
3247
3225
                os.close(c2pread)
3248
3226
                # Leave stderr and stdout open so we can see test noise
3298
3276
        bzr_path = [bzr_path]
3299
3277
        if sys.platform == "win32":
3300
3278
            # if we're on windows, we can't execute the bzr script directly
3301
 
            bzr_path = [sys.executable] + bzr_path
 
3279
            # and we have to enable unbuffered binary stdout/stderr so that
 
3280
            # automatic CRLF conversion doesn't corrupt the subunit streams
 
3281
            bzr_path = [sys.executable, '-u'] + bzr_path
3302
3282
        fd, test_list_file_name = tempfile.mkstemp()
3303
3283
        test_list_file = os.fdopen(fd, 'wb', 1)
3304
3284
        for test in process_tests:
3733
3713
        'bzrlib.tests.test_lru_cache',
3734
3714
        'bzrlib.tests.test_lsprof',
3735
3715
        'bzrlib.tests.test_mail_client',
3736
 
        'bzrlib.tests.test_matchers',
3737
3716
        'bzrlib.tests.test_memorytree',
3738
3717
        'bzrlib.tests.test_merge',
3739
3718
        'bzrlib.tests.test_merge3',
3819
3798
 
3820
3799
 
3821
3800
def _test_suite_modules_to_doctest():
3822
 
    """Return the list of modules to doctest."""
3823
 
    if __doc__ is None:
3824
 
        # GZ 2009-03-31: No docstrings with -OO so there's nothing to doctest
3825
 
        return []
 
3801
    """Return the list of modules to doctest."""   
3826
3802
    return [
3827
3803
        'bzrlib',
3828
3804
        'bzrlib.branchbuilder',