当前位置: 首页>>代码示例>>Python>>正文


Python ChiefController.close方法代码示例

本文整理汇总了Python中robotide.controller.ChiefController.close方法的典型用法代码示例。如果您正苦于以下问题:Python ChiefController.close方法的具体用法?Python ChiefController.close怎么用?Python ChiefController.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在robotide.controller.ChiefController的用法示例。


在下文中一共展示了ChiefController.close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestFindingControllers

# 需要导入模块: from robotide.controller import ChiefController [as 别名]
# 或者: from robotide.controller.ChiefController import close [as 别名]
class TestFindingControllers(unittest.TestCase):

    def setUp(self):
        self.chief = ChiefController(Namespace(FakeSettings()), FakeSettings(), _library_manager())

    def tearDown(self):
        self.chief.close()

    def test_finding_root_directory_controller(self):
        self.chief._controller = TestDataDirectoryController(_data_directory('Root'))
        result = self.chief.find_controller_by_longname('Root')
        assert_equals(result, self.chief._controller)

    def test_finding_subdirectory_controller(self):
        directory_controller = TestDataDirectoryController(_data_directory('Root'))
        subdirectory_controller = TestDataDirectoryController(_data_directory('Subsuite'))
        directory_controller.add_child(subdirectory_controller)
        self.chief._controller = directory_controller
        result = self.chief.find_controller_by_longname('Root.Subsuite')
        assert_equals(result, subdirectory_controller)

    def test_finding_testcase_controller(self):
        suite_controller = TestCaseFileController(_testcasefile('Suite.txt'))
        test = suite_controller.create_test('Test 1')
        self.chief._controller = suite_controller
        result = self.chief.find_controller_by_longname('Suite.Test 1')
        assert_equals(result, test)
开发者ID:blueenergy,项目名称:RIDE,代码行数:29,代码来源:test_chiefcontroller.py

示例2: TestFindingControllers

# 需要导入模块: from robotide.controller import ChiefController [as 别名]
# 或者: from robotide.controller.ChiefController import close [as 别名]
class TestFindingControllers(unittest.TestCase):

    def setUp(self):
        self.chief = ChiefController(Namespace(FakeSettings()), FakeSettings(), _library_manager())

    def tearDown(self):
        self.chief.close()

    def test_finding_root_directory_controller(self):
        self.chief._controller = TestDataDirectoryController(_data_directory('Root'))
        result = self.chief.find_controller_by_longname('Root')
        assert_equals(result, self.chief._controller)

    def test_finding_subdirectory_controller(self):
        directory_controller = TestDataDirectoryController(_data_directory('Root'))
        subdirectory_controller = TestDataDirectoryController(_data_directory('Sub.suite'))
        directory_controller.add_child(subdirectory_controller)
        self.chief._controller = directory_controller
        result = self.chief.find_controller_by_longname('Root.Sub.suite')
        assert_equals(result, subdirectory_controller)

    def test_finding_testcase_controller(self):
        suite_controller = TestCaseFileController(_testcasefile('Suite.txt'))
        test = suite_controller.create_test('Test 1')
        self.chief._controller = suite_controller
        result = self.chief.find_controller_by_longname('Suite.Test 1', 'Test 1')
        assert_equals(result, test)

    def test_finding_correct_testcase_when_two_with_same_name(self):
        test1, test2 = self._create_suite_structure_with_two_tests_with_same_name()
        result1 = self.chief.find_controller_by_longname('Ro.ot.'+test1.longname, test1.display_name)
        assert_equals(result1, test1)
        result2 = self.chief.find_controller_by_longname('Ro.ot.'+test2.longname, test2.display_name)
        assert_equals(result2, test2)

    def test_finding_correct_testcase_when_two_files_with_same_name_start(self):
        directory_controller = TestDataDirectoryController(_data_directory('t'))
        suite1_controller = TestCaseFileController(_testcasefile('test.txt'))
        test1 = suite1_controller.create_test('A')
        suite2_controller = TestCaseFileController(_testcasefile('test2.txt'))
        test2 = suite2_controller.create_test('A')
        directory_controller.add_child(suite1_controller)
        directory_controller.add_child(suite2_controller)
        self.chief._controller = directory_controller
        result1 = self.chief.find_controller_by_longname('T.'+test1.longname, test1.display_name)
        assert_equals(result1, test1)
        result2 = self.chief.find_controller_by_longname('T.'+test2.longname, test2.display_name)
        assert_equals(result2, test2)

    def _create_suite_structure_with_two_tests_with_same_name(self):
        directory_controller = TestDataDirectoryController(_data_directory('Ro.ot'))
        suite1_controller = TestCaseFileController(_testcasefile('Suite.1.txt'))
        test1 = suite1_controller.create_test('Te.st')
        suite2_controller = TestCaseFileController(_testcasefile('Suite.2.txt'))
        test2 = suite2_controller.create_test('Te.st')
        directory_controller.add_child(suite1_controller)
        directory_controller.add_child(suite2_controller)
        self.chief._controller = directory_controller
        return test1, test2
开发者ID:Acidburn0zzz,项目名称:RIDE,代码行数:61,代码来源:test_chiefcontroller.py

示例3: ChiefControllerTest

# 需要导入模块: from robotide.controller import ChiefController [as 别名]
# 或者: from robotide.controller.ChiefController import close [as 别名]
class ChiefControllerTest(unittest.TestCase):

    def setUp(self):
        self._library_manager = _library_manager()
        self.ctrl = ChiefController(Namespace(FakeSettings()), FakeSettings(), self._library_manager)
        self.load_observer = MessageRecordingLoadObserver()
        self.suite_listener = PublisherListener(RideOpenSuite)
        self.resource_listener = PublisherListener(RideOpenResource)

    def tearDown(self):
        self.suite_listener.unsubscribe()
        self.resource_listener.unsubscribe()
        self.ctrl.close()
        self._library_manager.stop()

    def test_loading_suite_at_startup(self):
        self._load(MINIMAL_SUITE_PATH)
        assert_true(self.ctrl._controller is not None)
        self._test_listeners([MINIMAL_SUITE_PATH], [])

    def _test_listeners(self, suite_paths, resource_paths):
        assert_equals(self._get_paths(self.suite_listener.data), suite_paths)
        assert_equals(self._get_paths(self.resource_listener.data), resource_paths)

    def _get_paths(self, data):
            return [item.path for item in data]

    def test_loading_resource_at_startup(self):
        self._load(RESOURCE_PATH)
        assert_true(self.ctrl.resources != [])
        self._test_listeners([], ALL_RESOURCE_PATH_RELATED_RESOURCE_IMPORTS)

    def test_loading_invalid_data_at_startup(self):
        msg = "Given file 'invalid' is not a valid Robot Framework test case or resource file."
        self.ctrl.load_data('invalid', self.load_observer)
        assert_true(self.load_observer.finished)
        assert_equals(self.load_observer.message, msg)
        self._test_listeners([], [])

    def _load(self, path):
        self.ctrl.load_data(path, self.load_observer)
        assert_true(self.load_observer.notified)
        assert_true(self.load_observer.finished)

    def test_loading_datafile(self):
        data = self.ctrl.load_datafile(MINIMAL_SUITE_PATH, self.load_observer)
        assert_true(self.load_observer.finished)
        assert_true(data is not None)
        self._test_listeners([MINIMAL_SUITE_PATH], [])

    def test_reloading(self):
        self.ctrl.new_file_project(MINIMAL_SUITE_PATH)
        files1 = self.ctrl.datafiles
        self.ctrl.new_file_project(MINIMAL_SUITE_PATH)
        files2 = self.ctrl.datafiles
        assert_true(files1 != files2)

    def test_loading_resource_file(self):
        resource = self.ctrl.load_resource(RESOURCE_PATH, self.load_observer)
        assert_true(self.load_observer.finished)
        assert_true(resource is not None)
        self._test_listeners([], ALL_RESOURCE_PATH_RELATED_RESOURCE_IMPORTS)

    def test_loading_invalid_datafile(self):
        self.ctrl.load_datafile('invalid', self.load_observer)
        assert_equals(self.load_observer.message, "Invalid data file 'invalid'.")
        self._test_listeners([], [])

    def test_loading_invalid_resource(self):
        assert_none(self.ctrl.load_resource('invalid', self.load_observer))
        assert_equals(self.load_observer.message, "Invalid resource file 'invalid'.")
        self._test_listeners([], [])

    def test_dirtyness(self):
        self.ctrl.load_data(COMPLEX_SUITE_PATH, MessageRecordingLoadObserver())
        assert_true(not self.ctrl.is_dirty())
        self.ctrl.data.create_test('newnessness')
        assert_true(self.ctrl.is_dirty())

    def test_load_dirty_controllers(self):
        self.ctrl.load_data(SUITEPATH, MessageRecordingLoadObserver())
        assert_equals(len(self.ctrl._get_all_dirty_controllers()), 0)
        tcf = self._find_suite_by_type(self.ctrl.data.children, TestCaseFileController)
        tcf.create_test('newnessness')
        assert_equals(len(self.ctrl._get_all_dirty_controllers()), 1)
        self.ctrl.data.mark_dirty()
        assert_equals(len(self.ctrl._get_all_dirty_controllers()), 2)
        sub_dir = self._find_suite_by_type(self.ctrl.data.children, TestDataDirectoryController)
        sub_dir_tcf = self._find_suite_by_type(sub_dir.children, TestCaseFileController)
        sub_dir_tcf.create_test('newnessness')
        assert_equals(len(self.ctrl._get_all_dirty_controllers()), 3)

    def _find_suite_by_type(self, suites, type):
        for child in suites:
            if isinstance(child, type):
                return child
        return None

    def test_creating_new_resource(self):
        controller = self.ctrl.new_resource('somepath')
#.........这里部分代码省略.........
开发者ID:blueenergy,项目名称:RIDE,代码行数:103,代码来源:test_chiefcontroller.py

示例4: TestResolvingResourceDirectories

# 需要导入模块: from robotide.controller import ChiefController [as 别名]
# 或者: from robotide.controller.ChiefController import close [as 别名]
class TestResolvingResourceDirectories(unittest.TestCase):

    def setUp(self):
        self.chief = ChiefController(Namespace(FakeSettings()), FakeSettings(), _library_manager())

    def tearDown(self):
        self.chief.close()

    def test_resource_file_outside_of_topsuite_is_an_external_resource(self):
        self._set_data_directory_controller('suite')
        self._set_resources(j('foo','resource.txt'))
        assert_equals(self.chief.external_resources, self.chief.resources)

    def _set_data_directory_controller(self, dir):
        self.chief._controller = TestDataDirectoryController(_data_directory(dir))

    def test_resource_file_in_own_directory_is_added_to_top_suite(self):
        self._set_data_directory_controller('foo')
        self._set_resources(j('foo','bar','quux.txt'))
        self._assert_resource_dir_was_created_as_child_of(self.chief.data)
        self._assert_resource_dir_contains_resources()
        assert_true(len(self.chief.external_resources)==  0)

    def test_two_resource_in_same_directory_get_same_parent(self):
        self._set_data_directory_controller('foo')
        self._set_resources(j('foo','bar','quux.txt'), j('foo','bar','zap.txt'))
        self._assert_resource_dir_was_created_as_child_of(self.chief.data)
        self._assert_resource_dir_contains_resources()

    def test_two_nested_resources_in_same_directory_get_same_parent(self):
        self._set_data_directory_controller('suite')
        self._set_resources(j('suite','foo','bar','quux.txt'), j('suite','foo','bar','zap.txt'))
        assert_equals(self.chief.data.children[0].children[0].children,
                      self.chief.resources)

    def test_resource_directory_gets_nearest_possible_parent(self):
        self._set_data_directory_controller('tmp')
        self.chief.data.add_child(TestDataDirectoryController(_data_directory(j('tmp','some'))))
        self._set_resources(j('tmp','some','resoruces','res.txt'))
        assert_equals(len(self.chief.data.children), 1)
        assert_equals(len(self.chief.data.children[0].children), 1)
        assert_equals(self.chief.data.children[0].children[0].children, [self.chief.resources[0]])

    def test_nested_resource_directories(self):
        self._set_data_directory_controller('tmp')
        self._set_resources(j('tmp','resoruces','res.txt'), j('tmp','resoruces','more','res.txt'))
        assert_equals(len(self.chief.data.children), 1)
        assert_equals(len(self.chief.data.children[0].children), 2)
        assert_equals(self.chief.data.children[0].children[1].children, [self.chief.resources[1]])

    def test_resource_in_nested_directory(self):
        self._set_data_directory_controller('tmp')
        self._set_resources(j('tmp','res','ources','res.txt'))
        assert_equals(len(self.chief.data.children), 1)
        assert_equals(len(self.chief.data.children[0].children), 1)
        assert_equals(self.chief.data.children[0].children[0].children, [self.chief.resources[0]])
        assert_true(len(self.chief.external_resources)==  0)

    def _set_resources(self, *paths):
        for p in paths:
            resource = ResourceFileController(ResourceFile(os.path.normpath(p)))
            self.chief.resources.append(resource)
            self.chief._insert_into_suite_structure(resource)

    def _assert_resource_dir_was_created_as_child_of(self, ctrl):
        assert_equals(len(ctrl.children), 1)

    def _assert_resource_dir_contains_resources(self):
        assert_equals(self.chief.data.children[0].children, self.chief.resources)
开发者ID:blueenergy,项目名称:RIDE,代码行数:71,代码来源:test_chiefcontroller.py


注:本文中的robotide.controller.ChiefController.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。