# Path: pylink/errors.py
# class JLinkException(enums.JLinkGlobalErrors, Exception):
#     """Generic J-Link exception."""
# 
#     def __init__(self, code):
#         """Generates an exception by coercing the given ``code`` to an error
#         string if is a number, otherwise assumes it is the message.
# 
#         Args:
#           self (JLinkException): the 'JLinkException' instance
#           code (object): message or error code
# 
#         Returns:
#           ``None``
#         """
#         message = code
# 
#         self.code = None
# 
#         if util.is_integer(code):
#             message = self.to_string(code)
#             self.code = code
# 
#         super(JLinkException, self).__init__(message)
#         self.message = message
# 
# class JLinkDataException(enums.JLinkDataErrors, JLinkException):
#     """J-Link data event exception."""
#     pass


import pylink.enums as enums
import pylink.jlink as jlink
import pylink.protocols.swd as swd
import pylink.structs as structs
import pylink.unlockers.unlock_kinetis as unlock_kinetis
import pylink.util as util
import mock
    import StringIO
    import io as StringIO
import ctypes
import itertools
import unittest
from pylink.errors import JLinkException, JLinkDataException
        """
        self.dll.JLINKARM_TRACE_Control.return_value = 1

        with self.assertRaises(JLinkException):
            self.jlink.trace_stop()

    def test_jlink_trace_stop_success(self):
        """Tests succeeding in stopping tracing.

        Args:
          self (TestJLink): the ``TestJLink`` instance

        Returns:
          ``None``
        """
        self.dll.JLINKARM_TRACE_Control.return_value = 0
        self.assertEqual(None, self.jlink.trace_stop())
        self.dll.JLINKARM_TRACE_Control.assert_called_once_with(1, 0)

    def test_jlink_trace_flush_failed(self):
        """Tests failing to flush the trace buffer.

        Args:
          self (TestJLink): the ``TestJLink`` instance

        Returns:
          ``None``
        """
        self.dll.JLINKARM_TRACE_Control.return_value = 1


# Path: pylink/errors.py
# class JLinkException(enums.JLinkGlobalErrors, Exception):
#     """Generic J-Link exception."""
# 
#     def __init__(self, code):
#         """Generates an exception by coercing the given ``code`` to an error
#         string if is a number, otherwise assumes it is the message.
# 
#         Args:
#           self (JLinkException): the 'JLinkException' instance
#           code (object): message or error code
# 
#         Returns:
#           ``None``
#         """
#         message = code
# 
#         self.code = None
# 
#         if util.is_integer(code):
#             message = self.to_string(code)
#             self.code = code
# 
#         super(JLinkException, self).__init__(message)
#         self.message = message
# 
# class JLinkDataException(enums.JLinkDataErrors, JLinkException):
#     """J-Link data event exception."""
#     pass


# Path: tests/unit/test_jlink.py
import pylink.enums as enums
import pylink.jlink as jlink
import pylink.protocols.swd as swd
import pylink.structs as structs
import pylink.unlockers.unlock_kinetis as unlock_kinetis
import pylink.util as util
import mock
    import StringIO
    import io as StringIO
import ctypes
import itertools
import unittest
from pylink.errors import JLinkException, JLinkDataException

        """
        self.dll.JLINKARM_TRACE_Control.return_value = 1

        with self.assertRaises(JLinkException):
            self.jlink.trace_stop()

    def test_jlink_trace_stop_success(self):
        """Tests succeeding in stopping tracing.

        Args:
          self (TestJLink): the ``TestJLink`` instance

        Returns:
          ``None``
        """
        self.dll.JLINKARM_TRACE_Control.return_value = 0
        self.assertEqual(None, self.jlink.trace_stop())
        self.dll.JLINKARM_TRACE_Control.assert_called_once_with(1, 0)

    def test_jlink_trace_flush_failed(self):
        """Tests failing to flush the trace buffer.

        Args:
          self (TestJLink): the ``TestJLink`` instance

        Returns:
          ``None``
        """
        self.dll.JLINKARM_TRACE_Control.return_value = 1


        with self.assertRaises(JLinkException):