old_contents: # ----------------------------------------------------------------------------
  # Copyright (c) 2013--, scikit-bio development team.
  #
  # Distributed under the terms of the Modified BSD License.
  #
  # The full license is in the file COPYING.txt, distributed with this software.
  # ----------------------------------------------------------------------------
  
  import os
  import inspect
  from nose import core
  from nose.tools import nottest
  from future.utils import PY3
  
  
  @nottest
  class TestRunner(object):
      """Simple wrapper class around nosetests functionality.
  
      Parameters
      ----------
      filename : __file__ attribute passed in from the caller. This tells the
          tester where to start looking for tests.
  
      Attributes
      ----------
      argv
      test_dir
  
      Notes
      -----
      The primary purpose of this class is to create an interface which users
      of scikit-bio can use to run all of the built in tests. Normally this
      would be done by invoking nosetests directly from the command line, but
      scikit-bio needs several additional options which make the command long
      and ugly. This class invokes nose with the required options.
  
      """
      def __init__(self, filename):
          self._filename = filename
          self._test_dir = os.path.dirname(filename)
  
      def test(self):
          """Performs the actual running of the tests.
          """
          # NOTE: it doesn't seem to matter what the first element of the argv
          # list is, there just needs to be something there.
          argv = [self._filename, '-I DO_NOT_IGNORE_ANYTHING']
          if not self.is_py3():
              argv.append('--with-doctest')
          core.run(argv=argv, defaultTest=self._test_dir)
  
      def is_py3(self):
          """Returns boolean indicating whether the user is running Python 3.
          This provides a flag for disabling doctests for Python 3.
          """
          return PY3
  
  
  def get_data_path(fn, subfolder='data'):
      """Return path to filename ``fn`` in the data folder.
  
      During testing it is often necessary to load data files. This
      function returns the full path to files in the ``data`` subfolder
      by default.
  
      Parameters
      ----------
      fn : str
          File name.
  
      subfolder : str, defaults to ``data``
          Name of the subfolder that contains the data.
  
  
      Returns
      -------
      str
          Inferred absolute path to the test data for the module where
          ``get_data_path(fn)`` is called.
  
      Notes
      -----
      The requested path may not point to an existing file, as its
      existence is not checked.
  
      """
      # getouterframes returns a list of tuples: the second tuple
      # contains info about the caller, and the second element is its
      # filename
      callers_filename = inspect.getouterframes(inspect.currentframe())[1][1]
      path = os.path.dirname(os.path.abspath(callers_filename))
      data_path = os.path.join(path, subfolder, fn)
      return data_path
  
new_contents: # ----------------------------------------------------------------------------
  # Copyright (c) 2013--, scikit-bio development team.
  #
  # Distributed under the terms of the Modified BSD License.
  #
  # The full license is in the file COPYING.txt, distributed with this software.
  # ----------------------------------------------------------------------------
  
  import os
  import inspect
  from nose import core
  from nose.tools import nottest
  from future.utils import PY3
  
  
  @nottest
  class TestRunner(object):
      """Simple wrapper class around nosetests functionality.
  
      Parameters
      ----------
      filename : __file__ attribute passed in from the caller. This tells the
          tester where to start looking for tests.
  
      Attributes
      ----------
      argv
      test_dir
  
      Notes
      -----
      The primary purpose of this class is to create an interface which users
      of scikit-bio can use to run all of the built in tests. Normally this
      would be done by invoking nosetests directly from the command line, but
      scikit-bio needs several additional options which make the command long
      and ugly. This class invokes nose with the required options.
  
      """
      def __init__(self, filename):
          self._filename = filename
          self._test_dir = os.path.dirname(filename)
  
      def test(self):
          """Performs the actual running of the tests.
          """
          # NOTE: it doesn't seem to matter what the first element of the argv
          # list is, there just needs to be something there.
          argv = [self._filename, '-I DO_NOT_IGNORE_ANYTHING']
          if not self.is_py3():
              argv.append('--with-doctest')
          core.run_exit(argv=argv, defaultTest=self._test_dir)
  
      def is_py3(self):
          """Returns boolean indicating whether the user is running Python 3.
          This provides a flag for disabling doctests for Python 3.
          """
          return PY3
  
  
  def get_data_path(fn, subfolder='data'):
      """Return path to filename ``fn`` in the data folder.
  
      During testing it is often necessary to load data files. This
      function returns the full path to files in the ``data`` subfolder
      by default.
  
      Parameters
      ----------
      fn : str
          File name.
  
      subfolder : str, defaults to ``data``
          Name of the subfolder that contains the data.
  
  
      Returns
      -------
      str
          Inferred absolute path to the test data for the module where
          ``get_data_path(fn)`` is called.
  
      Notes
      -----
      The requested path may not point to an existing file, as its
      existence is not checked.
  
      """
      # getouterframes returns a list of tuples: the second tuple
      # contains info about the caller, and the second element is its
      # filename
      callers_filename = inspect.getouterframes(inspect.currentframe())[1][1]
      path = os.path.dirname(os.path.abspath(callers_filename))
      data_path = os.path.join(path, subfolder, fn)
      return data_path
  
subject: Use nose run_exit method to get exit code