Example #1
0
def test_get_inherited_classes():
    temp_folder = utils.make_tmpdir()
    pkg_name = 'pike_mgr_inherited_classes'
    pkg_location = utils.create_working_package(temp_folder, pkg_name)

    test_file_content = textwrap.dedent("""
    class SampleObj(object):
        pass

    class OtherObj(SampleObj):
        pass
    """)

    mod_location = os.path.join(pkg_location, 'app.py')
    utils.write_file(mod_location, test_file_content)

    # Include module directly on the search path
    second_file = textwrap.dedent("""
    class AnotherObj(object):
        pass
    """)
    mod_location = os.path.join(temp_folder, 'more.py')
    utils.write_file(mod_location, second_file)

    classes = []
    with PikeManager([temp_folder]) as mgr:
        app = py.get_module_by_name('{}.app'.format(pkg_name))
        classes = mgr.get_all_inherited_classes(app.SampleObj)

    assert len(classes) == 1
Example #2
0
 def setup_method(self, method):
     self.temp_folder = utils.make_tmpdir()
     self.manager = PikeManager([self.temp_folder])
     self.pkg_name = 'pike_{}'.format(method.__name__)
     self.pkg_location = utils.create_working_package(
         self.temp_folder,
         self.pkg_name
     )
Example #3
0
    def setup_method(self, method):
        self.temp_folder = utils.make_tmpdir()

        # Create a simple package
        self.pkg_location = utils.create_working_package(
            self.temp_folder, 'compile_test')
        self.mod_location = os.path.join(self.pkg_location, 'app.py')
        utils.write_file(self.mod_location, SIMPLE_CLASS)

        py_compile.compile(self.mod_location)
Example #4
0
    def setup_method(self, method):
        self.temp_folder = utils.make_tmpdir()

        # Create a simple package
        pkg_location = utils.create_working_package(self.temp_folder)
        mod_location = os.path.join(pkg_location, 'app.py')
        utils.write_file(mod_location, SIMPLE_CLASS)

        self.finder = PikeFinder([self.temp_folder])
        self.loader = PikeLoader('pike_tests.app', mod_location)
Example #5
0
def compiled_loader():
    temp_folder = utils.make_tmpdir()

    # Create a simple package
    pkg_location = utils.create_working_package(temp_folder, 'compile_test')
    mod_location = os.path.join(pkg_location, 'app.py')
    utils.write_file(mod_location, SIMPLE_CLASS)

    py_compile.compile(mod_location)

    yield temp_folder

    utils.remove_dir(temp_folder)
Example #6
0
def compiled_loader():
    temp_folder = utils.make_tmpdir()

    # Create a simple package
    pkg_location = utils.create_working_package(temp_folder, 'compile_test')
    mod_location = os.path.join(pkg_location, 'app.py')
    utils.write_file(mod_location, SIMPLE_CLASS)

    py_compile.compile(mod_location)

    yield temp_folder

    utils.remove_dir(temp_folder)
Example #7
0
def loader_finder():
    temp_folder = utils.make_tmpdir()

    # Create a simple package
    pkg_location = utils.create_working_package(temp_folder)
    mod_location = os.path.join(pkg_location, 'app.py')
    utils.write_file(mod_location, SIMPLE_CLASS)

    finder = PikeFinder([temp_folder])
    loader = PikeLoader('pike_tests.app', mod_location)

    yield loader, finder

    utils.remove_dir(temp_folder)
Example #8
0
def loader_finder():
    temp_folder = utils.make_tmpdir()

    # Create a simple package
    pkg_location = utils.create_working_package(temp_folder)
    mod_location = os.path.join(pkg_location, 'app.py')
    utils.write_file(mod_location, SIMPLE_CLASS)

    finder = PikeFinder([temp_folder])
    loader = PikeLoader('pike_tests.app', mod_location)

    yield loader, finder

    utils.remove_dir(temp_folder)
Example #9
0
 def setup_method(self, method):
     self.temp_folder = utils.make_tmpdir()