from .base import PactBase
from .utils import GroupWaitPredicate


class PactGroup(PactBase):

    def __init__(self, pacts):
        self._pacts = list(pacts)
        super(PactGroup, self).__init__()

    def __iadd__(self, other):
        self._pacts.append(other)
        return self

    def _is_finished(self):
        return all(p.finished() for p in self._pacts)

    def _build_wait_predicate(self):
        return GroupWaitPredicate(self._pacts)

    def __str__(self):
        return ", ".join(map(str, self._pacts))

from .base import PactBase
from .utils import GroupWaitPredicate


class PactGroup(PactBase):

    def __init__(self, pacts=None):
        self._pacts = [] if pacts is None else list(pacts)
        super(PactGroup, self).__init__()

    def __iadd__(self, other):
        self._pacts.append(other)
        return self

    def _is_finished(self):
        return all(p.finished() for p in self._pacts)

    def _build_wait_predicate(self):
        return GroupWaitPredicate(self._pacts)

    def __str__(self):
        return ", ".join(map(str, self._pacts))

Create empty PactGroup if no arguments given
Create empty PactGroup if no arguments given
  from .base import PactBase
  from .utils import GroupWaitPredicate
  
  
  class PactGroup(PactBase):
  
-     def __init__(self, pacts):
+     def __init__(self, pacts=None):
-         self._pacts = list(pacts)
+         self._pacts = [] if pacts is None else list(pacts)
          super(PactGroup, self).__init__()
  
      def __iadd__(self, other):
          self._pacts.append(other)
          return self
  
      def _is_finished(self):
          return all(p.finished() for p in self._pacts)
  
      def _build_wait_predicate(self):
          return GroupWaitPredicate(self._pacts)
  
      def __str__(self):
          return ", ".join(map(str, self._pacts))
  
Create empty PactGroup if no arguments given
## Code Before:
from .base import PactBase
from .utils import GroupWaitPredicate


class PactGroup(PactBase):

    def __init__(self, pacts):
        self._pacts = list(pacts)
        super(PactGroup, self).__init__()

    def __iadd__(self, other):
        self._pacts.append(other)
        return self

    def _is_finished(self):
        return all(p.finished() for p in self._pacts)

    def _build_wait_predicate(self):
        return GroupWaitPredicate(self._pacts)

    def __str__(self):
        return ", ".join(map(str, self._pacts))

## Instruction:
Create empty PactGroup if no arguments given
## Code After:
from .base import PactBase
from .utils import GroupWaitPredicate


class PactGroup(PactBase):

    def __init__(self, pacts=None):
        self._pacts = [] if pacts is None else list(pacts)
        super(PactGroup, self).__init__()

    def __iadd__(self, other):
        self._pacts.append(other)
        return self

    def _is_finished(self):
        return all(p.finished() for p in self._pacts)

    def _build_wait_predicate(self):
        return GroupWaitPredicate(self._pacts)

    def __str__(self):
        return ", ".join(map(str, self._pacts))
