Пример #1
0
    def setup(self):
        self.context["testr_cmd"] = ["testr", "run", "--subunit"]
        run_args = self.verifier.manager.prepare_run_args(
            self.context.get("run_args", {}))

        concurrency = run_args.get("concurrency", 0)
        if concurrency == 0 or concurrency > 1:
            self.context["testr_cmd"].append("--parallel")
        if concurrency >= 1:
            self.context["testr_cmd"].extend(
                ["--concurrency", str(concurrency)])

        load_list = run_args.get("load_list")
        skip_list = run_args.get("skip_list")

        if skip_list:
            if not load_list:
                load_list = self.verifier.manager.list_tests()
            load_list = set(load_list) - set(skip_list)
        if load_list:
            load_list_file = common_utils.generate_random_path()
            with open(load_list_file, "w") as f:
                f.write("\n".join(load_list))
            self._tmp_files.append(load_list_file)
            self.context["testr_cmd"].extend(["--load-list", load_list_file])

        if run_args.get("failed"):
            self.context["testr_cmd"].append("--failing")

        if run_args.get("pattern"):
            self.context["testr_cmd"].append(run_args.get("pattern"))
Пример #2
0
 def __init__(self, chunk_size=10000, sep=" "):
     self.chunk_size = chunk_size
     self._sep = sep
     self._filename = cutils.generate_random_path()
     self._chunk = []
     self._current_chunk_size = 0
     self._deleted = False
Пример #3
0
    def setup(self):
        self.context["testr_cmd"] = ["testr", "run", "--subunit"]
        run_args = self.verifier.manager.prepare_run_args(
            self.context.get("run_args", {}))

        concurrency = run_args.get("concurrency", 0)
        if concurrency == 0 or concurrency > 1:
            self.context["testr_cmd"].append("--parallel")
        if concurrency >= 1:
            self.context["testr_cmd"].extend(
                ["--concurrency", str(concurrency)])

        load_list = run_args.get("load_list")
        skip_list = run_args.get("skip_list")

        if skip_list:
            if not load_list:
                load_list = self.verifier.manager.list_tests()
            load_list = set(load_list) - set(skip_list)
        if load_list:
            load_list_file = common_utils.generate_random_path()
            with open(load_list_file, "w") as f:
                f.write("\n".join(load_list))
            self._tmp_files.append(load_list_file)
            self.context["testr_cmd"].extend(["--load-list", load_list_file])

        if run_args.get("failed"):
            self.context["testr_cmd"].append("--failing")

        if run_args.get("pattern"):
            self.context["testr_cmd"].append(run_args.get("pattern"))
Пример #4
0
    def test_generate_random_path(self, mock_uuid, mock_exists):
        mock_exists.side_effect = lambda a: "exist" in a
        mock_uuid.uuid4.side_effect = ("exist", "foo")

        self.assertEqual("/some/foo", utils.generate_random_path("/some"))

        mock_exists.assert_has_calls((
            mock.call("/some/exist"),
            mock.call("/some/foo"),
        ))
Пример #5
0
    def test_generate_random_path(self, mock_uuid, mock_exists):
        mock_exists.side_effect = lambda a: "exist" in a
        mock_uuid.uuid4.side_effect = ("exist", "foo")

        self.assertEqual("/some/foo", utils.generate_random_path("/some"))

        mock_exists.assert_has_calls((
            mock.call("/some/exist"),
            mock.call("/some/foo"),
        ))
Пример #6
0
    def setup(self):
        super(TestrContext, self).setup()
        use_testr = getattr(self.verifier.manager, "_use_testr", True)

        if use_testr:
            base_cmd = "testr"
        else:
            base_cmd = "stestr"
        self.context["testr_cmd"] = [base_cmd, "run", "--subunit"]
        run_args = self.verifier.manager.prepare_run_args(
            self.context.get("run_args", {}))

        concurrency = run_args.get("concurrency", 0)
        if concurrency == 0 or concurrency > 1:
            if use_testr:
                self.context["testr_cmd"].append("--parallel")
        if concurrency >= 1:
            if concurrency == 1 and not use_testr:
                self.context["testr_cmd"].append("--serial")
            else:
                self.context["testr_cmd"].extend(
                    ["--concurrency", str(concurrency)])

        load_list = self.context.get("load_list")
        skip_list = self.context.get("skip_list")

        if skip_list:
            load_list = set(load_list) - set(skip_list)
        if load_list:
            load_list_file = common_utils.generate_random_path()
            with open(load_list_file, "w") as f:
                f.write("\n".join(load_list))
            self._tmp_files.append(load_list_file)
            self.context["testr_cmd"].extend(["--load-list", load_list_file])

        if run_args.get("failed"):
            self.context["testr_cmd"].append("--failing")

        if run_args.get("pattern"):
            self.context["testr_cmd"].append(run_args.get("pattern"))