/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

Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
 
88
88
MODULES_TO_TEST = []
89
89
MODULES_TO_DOCTEST = [
90
 
                      bzrlib.branch,
91
90
                      bzrlib.bundle.serializer,
92
 
                      bzrlib.commands,
93
91
                      bzrlib.errors,
94
92
                      bzrlib.export,
95
93
                      bzrlib.inventory,
97
95
                      bzrlib.lockdir,
98
96
                      bzrlib.merge3,
99
97
                      bzrlib.option,
100
 
                      bzrlib.osutils,
101
98
                      bzrlib.store,
102
 
                      bzrlib.transport,
103
99
                      ]
104
100
 
105
101
 
931
927
            The values must be strings. The change will only occur in the
932
928
            child, so you don't need to fix the environment after running.
933
929
        :param universal_newlines: Convert CRLF => LF
 
930
        :param allow_plugins: By default the subprocess is run with
 
931
            --no-plugins to ensure test reproducibility. Also, it is possible
 
932
            for system-wide plugins to create unexpected output on stderr,
 
933
            which can cause unnecessary test failures.
934
934
        """
935
935
        env_changes = kwargs.get('env_changes', {})
936
936
        working_dir = kwargs.get('working_dir', None)
 
937
        allow_plugins = kwargs.get('allow_plugins', False)
937
938
        process = self.start_bzr_subprocess(args, env_changes=env_changes,
938
 
                                            working_dir=working_dir)
 
939
                                            working_dir=working_dir,
 
940
                                            allow_plugins=allow_plugins)
939
941
        # We distinguish between retcode=None and retcode not passed.
940
942
        supplied_retcode = kwargs.get('retcode', 0)
941
943
        return self.finish_bzr_subprocess(process, retcode=supplied_retcode,
944
946
 
945
947
    def start_bzr_subprocess(self, process_args, env_changes=None,
946
948
                             skip_if_plan_to_signal=False,
947
 
                             working_dir=None):
 
949
                             working_dir=None,
 
950
                             allow_plugins=False):
948
951
        """Start bzr in a subprocess for testing.
949
952
 
950
953
        This starts a new Python interpreter and runs bzr in there.
961
964
            child, so you don't need to fix the environment after running.
962
965
        :param skip_if_plan_to_signal: raise TestSkipped when true and os.kill
963
966
            is not available.
 
967
        :param allow_plugins: If False (default) pass --no-plugins to bzr.
964
968
 
965
969
        :returns: Popen object for the started process.
966
970
        """
992
996
            # so we will avoid using it on all platforms, just to
993
997
            # make sure the code path is used, and we don't break on win32
994
998
            cleanup_environment()
995
 
            process = Popen([sys.executable, bzr_path] + list(process_args),
996
 
                             stdin=PIPE, stdout=PIPE, stderr=PIPE)
 
999
            command = [sys.executable, bzr_path]
 
1000
            if not allow_plugins:
 
1001
                command.append('--no-plugins')
 
1002
            command.extend(process_args)
 
1003
            process = self._popen(command, stdin=PIPE, stdout=PIPE, stderr=PIPE)
997
1004
        finally:
998
1005
            restore_environment()
999
1006
            if cwd is not None:
1001
1008
 
1002
1009
        return process
1003
1010
 
 
1011
    def _popen(self, *args, **kwargs):
 
1012
        """Place a call to Popen.
 
1013
 
 
1014
        Allows tests to override this method to intercept the calls made to
 
1015
        Popen for introspection.
 
1016
        """
 
1017
        return Popen(*args, **kwargs)
 
1018
 
1004
1019
    def get_bzr_path(self):
1005
1020
        """Return the path of the 'bzr' executable for this test suite."""
1006
1021
        bzr_path = os.path.dirname(os.path.dirname(bzrlib.__file__))+'/bzr'
1293
1308
        made_control = self.make_bzrdir(relpath, format=format)
1294
1309
        return made_control.create_repository(shared=shared)
1295
1310
 
1296
 
    def make_branch_and_memory_tree(self, relpath):
 
1311
    def make_branch_and_memory_tree(self, relpath, format=None):
1297
1312
        """Create a branch on the default transport and a MemoryTree for it."""
1298
 
        b = self.make_branch(relpath)
 
1313
        b = self.make_branch(relpath, format=format)
1299
1314
        return memorytree.MemoryTree.create_on_branch(b)
1300
1315
 
1301
1316
    def overrideEnvironmentForTesting(self):
1637
1652
                   'bzrlib.tests.test_plugins',
1638
1653
                   'bzrlib.tests.test_progress',
1639
1654
                   'bzrlib.tests.test_reconcile',
 
1655
                   'bzrlib.tests.test_registry',
1640
1656
                   'bzrlib.tests.test_repository',
1641
1657
                   'bzrlib.tests.test_revert',
1642
1658
                   'bzrlib.tests.test_revision',
1690
1706
    for m in MODULES_TO_TEST:
1691
1707
        suite.addTest(loader.loadTestsFromModule(m))
1692
1708
    for m in MODULES_TO_DOCTEST:
1693
 
        suite.addTest(doctest.DocTestSuite(m))
 
1709
        try:
 
1710
            suite.addTest(doctest.DocTestSuite(m))
 
1711
        except ValueError, e:
 
1712
            print '**failed to get doctest for: %s\n%s' %(m,e)
 
1713
            raise
1694
1714
    for name, plugin in bzrlib.plugin.all_plugins().items():
1695
1715
        if getattr(plugin, 'test_suite', None) is not None:
1696
1716
            suite.addTest(plugin.test_suite())