How to use the dictdiffer.resolve.UnresolvedConflictsException function in dictdiffer

To help you get started, we’ve selected a few dictdiffer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github inveniosoftware / dictdiffer / tests / test_resolve.py View on Github external
def test_resolve_conflicts(self):
        p1 = ('add', 'foo', [(0, 0)])
        p2 = ('add', 'foo', [(0, 1)])
        c = [Conflict(p1, p2)]

        # KeyError
        r = Resolver({})

        self.assertRaises(UnresolvedConflictsException,
                          r.resolve_conflicts, [p1], [p2], c)

        # Failing action
        r = Resolver({('foo', 0): lambda *args: False})

        self.assertRaises(UnresolvedConflictsException,
                          r.resolve_conflicts, [p1], [p2], c)

        # No further resolution exception
        def no_further(*args):
            raise NoFurtherResolutionException

        r = Resolver({('foo', 0): no_further})
        self.assertRaises(UnresolvedConflictsException,
                          r.resolve_conflicts, [p1], [p2], c)
github inveniosoftware / dictdiffer / tests / test_resolve.py View on Github external
def test_message(self):
        e = UnresolvedConflictsException(None)
        m = ("The unresolved conflicts are stored in the *content* "
             "attribute of this exception or in the "
             "*unresolved_conflicts* attribute of the "
             "dictdiffer.merge.Merger object.")

        self.assertEqual(m, str(e))
        self.assertEqual(m, e.__repr__())
        self.assertEqual(m, e.__str__())
github inveniosoftware / dictdiffer / tests / test_resolve.py View on Github external
def test_content(self):
        e = UnresolvedConflictsException(None)
        self.assertEqual(None, e.content)
github inveniosoftware / dictdiffer / dictdiffer / resolve.py View on Github external
if self.actions[sub_path](conflict,
                                              first_patches,
                                              second_patches,
                                              self.additional_info):
                        break
                except NoFurtherResolutionException:
                    self.unresolved_conflicts.append(conflict)
                    break
                except KeyError:
                    pass
            else:
                # The conflict could not be resolved
                self.unresolved_conflicts.append(conflict)

        if self.unresolved_conflicts:
            raise UnresolvedConflictsException(self.unresolved_conflicts)
github inveniosoftware / dictdiffer / dictdiffer / merge.py View on Github external
def run(self):
        """Run the automated merging process.

        Runs every step necessary for the automated merging process, raising
        an UnresolvedConflictsException in case that the provided resolution
        actions can not solve a given conflict.

        After every performed step, the results are stored inside attributes of
        the merger object.
        """
        self.extract_patches()
        self.find_conflicts()
        self.resolve_conflicts()

        if self.unresolved_conflicts:
            raise UnresolvedConflictsException(self.unresolved_conflicts)

        self.unify_patches()
github inveniosoftware / dictdiffer / dictdiffer / resolve.py View on Github external
def manual_resolve_conflicts(self, picks):
        """Resolve manually the conflicts.

        This method resolves conflicts that could not be resolved in an
        automatic way. The picks parameter utilized the *take* attribute of the
        Conflict objects.

        :param picks: list of 'f' or 's' strings, utilizing the *take*
                      parameter of each Conflict object
        """
        if len(picks) != len(self.unresolved_conflicts):
            raise UnresolvedConflictsException(self.unresolved_conflicts)
        for pick, conflict in zip(picks, self.unresolved_conflicts):
            conflict.take = pick

        self.unresolved_conflicts = []