# Path: pythoscope/util.py
# def generator_has_ended(generator):
#     """Return True if the generator has been exhausted and False otherwise.
# 
#     >>> generator_has_ended(1)
#     Traceback (most recent call last):
#       ...
#     TypeError: argument is not a generator
#     """
#     if not isinstance(generator, types.GeneratorType):
#         raise TypeError("argument is not a generator")
#     return _generator_has_ended(generator)


import sys
from nose import SkipTest
from pythoscope.inspector import inspect_project
from pythoscope.util import generator_has_ended
from assertions import *
from helper import CapturedLogger, CapturedDebugLogger, P, ProjectInDirectory,\
    TempDirectory
    def test_reports_each_inspected_point_of_entry(self):
        paths = ["one.py", "two.py"]
        project = ProjectInDirectory(self.tmpdir).with_points_of_entry(paths)

        inspect_project(project)

        for path in paths:
            assert_contains_once(self._get_log_output(),
                                 "INFO: Inspecting point of entry %s." % path)

    def test_warns_about_unreliable_implementation_of_util_generator_has_ended(self):
        if not hasattr(generator_has_ended, 'unreliable'):
            raise SkipTest

        paths = ["edgar.py", "allan.py"]
        project = ProjectInDirectory(self.tmpdir).with_points_of_entry(paths)

        inspect_project(project)

        assert_contains_once(self._get_log_output(),
                             "WARNING: Pure Python implementation of "
                             "util.generator_has_ended is not reliable on "
                             "Python 2.4 and lower. Please compile the _util "
                             "module or use Python 2.5 or higher.")

    def test_catches_exceptions_raised_by_entry_points(self):
        project = ProjectInDirectory(self.tmpdir).with_point_of_entry("exc.py", "raise Exception")
        inspect_project(project)
        if sys.version_info < (2, 5):
            assert_contains_once(self._get_log_output(),

# Path: pythoscope/util.py
# def generator_has_ended(generator):
#     """Return True if the generator has been exhausted and False otherwise.
# 
#     >>> generator_has_ended(1)
#     Traceback (most recent call last):
#       ...
#     TypeError: argument is not a generator
#     """
#     if not isinstance(generator, types.GeneratorType):
#         raise TypeError("argument is not a generator")
#     return _generator_has_ended(generator)


# Path: test/test_inspector.py
import sys
from nose import SkipTest
from pythoscope.inspector import inspect_project
from pythoscope.util import generator_has_ended
from assertions import *
from helper import CapturedLogger, CapturedDebugLogger, P, ProjectInDirectory,\
    TempDirectory

    def test_reports_each_inspected_point_of_entry(self):
        paths = ["one.py", "two.py"]
        project = ProjectInDirectory(self.tmpdir).with_points_of_entry(paths)

        inspect_project(project)

        for path in paths:
            assert_contains_once(self._get_log_output(),
                                 "INFO: Inspecting point of entry %s." % path)

    def test_warns_about_unreliable_implementation_of_util_generator_has_ended(self):
        if not hasattr(generator_has_ended, 'unreliable'):
            raise SkipTest

        paths = ["edgar.py", "allan.py"]
        project = ProjectInDirectory(self.tmpdir).with_points_of_entry(paths)

        inspect_project(project)

        assert_contains_once(self._get_log_output(),
                             "WARNING: Pure Python implementation of "
                             "util.generator_has_ended is not reliable on "
                             "Python 2.4 and lower. Please compile the _util "
                             "module or use Python 2.5 or higher.")

    def test_catches_exceptions_raised_by_entry_points(self):
        project = ProjectInDirectory(self.tmpdir).with_point_of_entry("exc.py", "raise Exception")
        inspect_project(project)
        if sys.version_info < (2, 5):
            assert_contains_once(self._get_log_output(),

                                 "WARNING: Point of entry exited with error: <exceptions.Exception instance at")