# Path: tt/definitions/operators.py
# BINARY_OPERATORS = {
#     TT_AND_OP,
#     TT_IMPL_OP,
#     TT_NAND_OP,
#     TT_NOR_OP,
#     TT_OR_OP,
#     TT_XNOR_OP,
#     TT_XOR_OP
# }
# 
# TT_AND_OP = BooleanOperator(_PRECEDENCE['LOW'],
#                             lambda a, b: a and b,
#                             '/\\', 'and')
# 
# TT_OR_OP = BooleanOperator(_PRECEDENCE['ZERO'],
#                            lambda a, b: a or b,
#                            '\\/', 'or')
# 
# Path: tt/tests/unit/trees/_helpers.py
# class ExpressionTreeAndNodeTestCase(unittest.TestCase):
# 
#     def get_tree_root_from_expr_str(self, expr_str):
#         """Get an tree root node from an expression string."""
#         return BooleanExpression(expr_str).tree


from tt.definitions import (
    BINARY_OPERATORS,
    TT_AND_OP,
    TT_OR_OP)
from ._helpers import ExpressionTreeAndNodeTestCase
"""Test node transformation to apply De Morgan's Law."""




class TestNodeApplyDeMorgans(ExpressionTreeAndNodeTestCase):

    def test_single_operand(self):
        """Test that no change occurs for a single operand."""
        root = self.get_tree_root_from_expr_str('A')
        demo = root.apply_de_morgans()
        self.assertTrue(demo is not root)
        self.assertEqual(
            str(demo),
            'A')

    def test_unaffected_binary_operators(self):
        """Test that no change occurs for non-AND and non-OR binary ops."""

# Path: tt/definitions/operators.py
# BINARY_OPERATORS = {
#     TT_AND_OP,
#     TT_IMPL_OP,
#     TT_NAND_OP,
#     TT_NOR_OP,
#     TT_OR_OP,
#     TT_XNOR_OP,
#     TT_XOR_OP
# }
# 
# TT_AND_OP = BooleanOperator(_PRECEDENCE['LOW'],
#                             lambda a, b: a and b,
#                             '/\\', 'and')
# 
# TT_OR_OP = BooleanOperator(_PRECEDENCE['ZERO'],
#                            lambda a, b: a or b,
#                            '\\/', 'or')
# 
# Path: tt/tests/unit/trees/_helpers.py
# class ExpressionTreeAndNodeTestCase(unittest.TestCase):
# 
#     def get_tree_root_from_expr_str(self, expr_str):
#         """Get an tree root node from an expression string."""
#         return BooleanExpression(expr_str).tree


# Path: tt/tests/unit/trees/test_node_apply_de_morgans.py
from tt.definitions import (
    BINARY_OPERATORS,
    TT_AND_OP,
    TT_OR_OP)
from ._helpers import ExpressionTreeAndNodeTestCase

"""Test node transformation to apply De Morgan's Law."""




class TestNodeApplyDeMorgans(ExpressionTreeAndNodeTestCase):

    def test_single_operand(self):
        """Test that no change occurs for a single operand."""
        root = self.get_tree_root_from_expr_str('A')
        demo = root.apply_de_morgans()
        self.assertTrue(demo is not root)
        self.assertEqual(
            str(demo),
            'A')

    def test_unaffected_binary_operators(self):
        """Test that no change occurs for non-AND and non-OR binary ops."""

        for op in (BINARY_OPERATORS - {TT_AND_OP, TT_OR_OP}):