from builtins import object
import unittest

from gaphas.state import reversible_pair, observed, _reverse

class SList(object):
    def __init__(self):
        self.l = list()
    def add(self, node, before=None):
        if before: self.l.insert(self.l.index(before), node)
        else: self.l.append(node)
    add = observed(add)
    @observed
    def remove(self, node):
        self.l.remove(self.l.index(node))

class StateTestCase(unittest.TestCase):
    def test_adding_pair(self):
        """Test adding reversible pair
        """
        reversible_pair(SList.add, SList.remove, \
            bind1={'before': lambda self, node: self.l[self.l.index(node)+1] })

        self.assertTrue(SList.add.__func__ in _reverse)
        self.assertTrue(SList.remove.__func__ in _reverse)

from builtins import object
import unittest

from gaphas.state import reversible_pair, observed, _reverse

class SList(object):
    def __init__(self):
        self.l = list()
    def add(self, node, before=None):
        if before: self.l.insert(self.l.index(before), node)
        else: self.l.append(node)
    add = observed(add)
    @observed
    def remove(self, node):
        self.l.remove(self.l.index(node))

class StateTestCase(unittest.TestCase):
    def test_adding_pair(self):
        """Test adding reversible pair
        """
        reversible_pair(SList.add, SList.remove, \
            bind1={'before': lambda self, node: self.l[self.l.index(node)+1] })

        self.assertTrue(SList.add in _reverse)
        self.assertTrue(SList.remove in _reverse)

Fix function object has no attribute __func__
Fix function object has no attribute __func__

Signed-off-by: Dan Yeaw <2591e5f46f28d303f9dc027d475a5c60d8dea17a@yeaw.me>

  from builtins import object
  import unittest
  
  from gaphas.state import reversible_pair, observed, _reverse
  
  class SList(object):
      def __init__(self):
          self.l = list()
      def add(self, node, before=None):
          if before: self.l.insert(self.l.index(before), node)
          else: self.l.append(node)
      add = observed(add)
      @observed
      def remove(self, node):
          self.l.remove(self.l.index(node))
  
  class StateTestCase(unittest.TestCase):
      def test_adding_pair(self):
          """Test adding reversible pair
          """
          reversible_pair(SList.add, SList.remove, \
              bind1={'before': lambda self, node: self.l[self.l.index(node)+1] })
  
-         self.assertTrue(SList.add.__func__ in _reverse)
+         self.assertTrue(SList.add in _reverse)
-         self.assertTrue(SList.remove.__func__ in _reverse)
+         self.assertTrue(SList.remove in _reverse)
  
Fix function object has no attribute __func__
## Code Before:
from builtins import object
import unittest

from gaphas.state import reversible_pair, observed, _reverse

class SList(object):
    def __init__(self):
        self.l = list()
    def add(self, node, before=None):
        if before: self.l.insert(self.l.index(before), node)
        else: self.l.append(node)
    add = observed(add)
    @observed
    def remove(self, node):
        self.l.remove(self.l.index(node))

class StateTestCase(unittest.TestCase):
    def test_adding_pair(self):
        """Test adding reversible pair
        """
        reversible_pair(SList.add, SList.remove, \
            bind1={'before': lambda self, node: self.l[self.l.index(node)+1] })

        self.assertTrue(SList.add.__func__ in _reverse)
        self.assertTrue(SList.remove.__func__ in _reverse)

## Instruction:
Fix function object has no attribute __func__
## Code After:
from builtins import object
import unittest

from gaphas.state import reversible_pair, observed, _reverse

class SList(object):
    def __init__(self):
        self.l = list()
    def add(self, node, before=None):
        if before: self.l.insert(self.l.index(before), node)
        else: self.l.append(node)
    add = observed(add)
    @observed
    def remove(self, node):
        self.l.remove(self.l.index(node))

class StateTestCase(unittest.TestCase):
    def test_adding_pair(self):
        """Test adding reversible pair
        """
        reversible_pair(SList.add, SList.remove, \
            bind1={'before': lambda self, node: self.l[self.l.index(node)+1] })

        self.assertTrue(SList.add in _reverse)
        self.assertTrue(SList.remove in _reverse)
