Example #1
0
    def _getSuite(self, test):
        if hasattr(test, "suite"):
            suite = strclass(test.suite)
            suite_location = test.suite.location
            location = test.suite.abs_location
            if hasattr(test, "lineno"):
                location = location + ":" + str(test.lineno)
            else:
                location = location + ":" + str(test.test.lineno)
        else:
            suite = strclass(test.__class__)
            suite_location = "python_nosetestid://" + suite
            try:
                from nose.util import func_lineno

                if hasattr(test.test, "descriptor") and test.test.descriptor:
                    suite_location = "file://" + self.test_address(
                        test.test.descriptor)
                    location = suite_location + ":" + str(
                        func_lineno(test.test.descriptor))
                else:
                    suite_location = "file://" + self.test_address(
                        test.test.test)
                    location = "file://" + self.test_address(
                        test.test.test) + ":" + str(func_lineno(
                            test.test.test))
            except:
                test_id = test.id()
                suite_id = test_id[:test_id.rfind(".")]
                suite_location = "python_nosetestid://" + str(suite_id)
                location = "python_nosetestid://" + str(test_id)
        return (location, suite_location)
  def _getSuite(self, test):
    if hasattr(test, "suite"):
      suite = strclass(test.suite)
      suite_location = test.suite.location
      location = test.suite.abs_location
      if hasattr(test, "lineno"):
        location = location + ":" + str(test.lineno)
      else:
        location = location + ":" + str(test.test.lineno)
    else:
      suite = strclass(test.__class__)
      suite_location = "python_nosetestid://" + suite
      try:
        from nose.util import func_lineno

        if hasattr(test.test, "descriptor") and test.test.descriptor:
          suite_location = "file://" + self.test_address(
            test.test.descriptor)
          location = suite_location + ":" + str(
            func_lineno(test.test.descriptor))
        else:
          suite_location = "file://" + self.test_address(
            test.test.test)
          location = "file://" + self.test_address(
            test.test.test) + ":" + str(func_lineno(test.test.test))
      except:
        test_id = test.id()
        suite_id = test_id[:test_id.rfind(".")]
        suite_location = "python_nosetestid://" + str(suite_id)
        location = "python_nosetestid://" + str(test_id)
    return (location, suite_location)
Example #3
0
 def cmp_line(a, b):
     """Compare functions by their line numbers
     """
     try:
         a_ln = func_lineno(a)
         b_ln = func_lineno(b)
     except AttributeError:
         return 0
     return cmp(a_ln, b_ln)
Example #4
0
    def test_decorator_func_sorting(self):
        from nose.tools import raises, timed, with_setup
        from nose.util import func_lineno

        def test1():
            pass

        def test2():
            pass

        def test3():
            pass

        def foo():
            pass

        test1_pos = func_lineno(test1)
        test2_pos = func_lineno(test2)
        test3_pos = func_lineno(test3)

        test1 = raises(TypeError)(test1)
        test2 = timed(1.0)(test2)
        test3 = with_setup(foo)(test3)

        self.assertEqual(func_lineno(test1), test1_pos)
        self.assertEqual(func_lineno(test2), test2_pos)
        self.assertEqual(func_lineno(test3), test3_pos)
Example #5
0
    def test_decorator_func_sorting(self):
        from nose.tools import raises, timed, with_setup
        from nose.util import func_lineno

        def test1():
            pass

        def test2():
            pass

        def test3():
            pass

        def foo():
            pass

        test1_pos = func_lineno(test1)
        test2_pos = func_lineno(test2)
        test3_pos = func_lineno(test3)

        test1 = raises(TypeError)(test1)
        test2 = timed(1.0)(test2)
        test3 = with_setup(foo)(test3)

        self.assertEqual(func_lineno(test1), test1_pos)
        self.assertEqual(func_lineno(test2), test2_pos)
        self.assertEqual(func_lineno(test3), test3_pos)