def test_two_sub_graph_circle(): graph = OrderedDict() graph["F"] = () graph["E"] = () graph["D"] = "E", "F" graph["A"] = "B", "C" graph["B"] = ("A", ) graph["C"] = () with pytest.raises(ValueError, match="A | B"): stable_topological_sort(graph)
def __init__(self, config, popen=subprocess.Popen, Report=Reporter): self.config = config self.popen = popen self.resultlog = ResultLog() self.report = Report(self) self.make_emptydir(config.logdir) config.logdir.ensure(dir=1) self.report.using("tox.ini: {}".format(self.config.toxinipath)) self._spec2pkg = {} self._name2venv = {} try: self.venvlist = [ self.getvenv(x) for x in self.evaluated_env_list() ] except LookupError: raise SystemExit(1) except tox.exception.ConfigError as exception: self.report.error(str(exception)) raise SystemExit(1) try: self.venv_order = stable_topological_sort( OrderedDict( (v.name, v.envconfig.depends) for v in self.venvlist)) except ValueError as exception: self.report.error( "circular dependency detected: {}".format(exception)) raise SystemExit(1) self._actions = []
def test_topological_order(): graph = OrderedDict() graph["A"] = "B", "C" graph["B"] = () graph["C"] = () result = stable_topological_sort(graph) assert result == ["B", "C", "A"]
def test_topological_complex(): graph = OrderedDict() graph["A"] = "B", "C" graph["B"] = "C", "D" graph["C"] = ("D", ) graph["D"] = () result = stable_topological_sort(graph) assert result == ["D", "C", "B", "A"]
def test_two_sub_graph(): graph = OrderedDict() graph["F"] = () graph["E"] = () graph["D"] = "E", "F" graph["A"] = "B", "C" graph["B"] = () graph["C"] = () result = stable_topological_sort(graph) assert result == ["F", "E", "D", "B", "C", "A"]
def _build_venvs(self): try: need_to_run = OrderedDict((v, self.getvenv(v)) for v in self._evaluated_env_list) try: venv_order = stable_topological_sort( OrderedDict((name, v.envconfig.depends) for name, v in need_to_run.items()), ) venvs = OrderedDict((v, need_to_run[v]) for v in venv_order) return venvs except ValueError as exception: reporter.error("circular dependency detected: {}".format(exception)) except LookupError: pass except tox.exception.ConfigError as exception: reporter.error(str(exception)) raise SystemExit(1)
def test_topological_order_specified_only(): graph = OrderedDict() graph["A"] = "B", "C" result = stable_topological_sort(graph) assert result == ["A"]
def test_topological_order_cycle(): graph = OrderedDict() graph["A"] = "B", "C" graph["B"] = ("A", ) with pytest.raises(ValueError, match="A | B"): stable_topological_sort(graph)