Beispiel #1
0
 def _yield_list_diffs(self, list1, list2, names):
     for index, (item1, item2) in enumerate(zip(list1, list2)):
         name = ' (%s)' % names[index] if index in names else ''
         try:
             assert_equals(item1, item2, msg='Index %d%s' % (index, name))
         except AssertionError as err:
             yield unic(err)
 def test_output_files_as_none_object(self):
     for name in 'Output', 'Report', 'Log', 'XUnit', 'DebugFile':
         attr = (name[:-4] if name.endswith('File') else name).lower()
         settings = RobotSettings({name.lower(): None})
         assert_equals(settings[name], None)
         if hasattr(settings, attr):
             assert_equals(getattr(settings, attr), None)
 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.project._controller = directory_controller
     result = self.project.find_controller_by_longname('Root.Sub.suite')
     assert_equals(result, subdirectory_controller)
 def test_delete_keyword_undo(self):
     new_kw_name = 'Jiihaa'
     self._exec(AddKeyword(new_kw_name))
     self._exec(RemoveMacro(self._new_keyword))
     self._new_keyword = None
     self._exec(Undo())
     assert_equals(self._new_keyword.name, new_kw_name)
Beispiel #5
0
 def test_negative(self):
     for number in range(1000):
         number *= -1
         for extra in range(5):
             extra /= 10.0
             assert_equals(roundup(number + extra), number)
             assert_equals(roundup(number - extra), number)
Beispiel #6
0
 def test_removing_user_keyword(self):
     name = self._model.data.children[1].keywords[1].name
     root = self._tree._root
     count = self._tree.GetChildrenCount(self._tree._root)
     self._tree.Delete(
         self._tree._controller.find_node_with_label(root, name))
     assert_equals(count - 1, self._tree.GetChildrenCount(self._tree._root))
 def test_import_class_from_file(self):
     path = create_temp_file('test.py', extra_content='class test:\n def m(s): return 1')
     klass = self._import(path, remove='test')
     self._assert_imported_message('test', path, type='class')
     assert_true(inspect.isclass(klass))
     assert_equals(klass.__name__, 'test')
     assert_equals(klass().m(), 1)
Beispiel #8
0
 def test_add_test_or_kw(self):
     assert_equals(len(self.ctrl.tests), 0)
     new_test = TestCaseController(self.ctrl, TestCase(TestCaseFile(), 'New test'))
     self.ctrl.add_test_or_keyword(new_test)
     assert_equals(len(self.ctrl.tests), 1)
     assert_true(self.ctrl.tests[0]._test.parent.parent is self.ctrl.datafile)
     assert_true(self.ctrl.dirty)
Beispiel #9
0
def check_for_variable_occurrences(test_ctrl, name, expected_occurrences):
    occurrences = list(test_ctrl.execute(FindVariableOccurrences(name)))
    processed_occurrences = 0
    for source, usage, count in expected_occurrences:
        assert_variable_occurrence(occurrences, source, usage, count)
        processed_occurrences += count
    assert_equals(processed_occurrences, len(occurrences))
 def test_test_data(self):
     test = build('pass_and_fail.robot').tests[1]
     assert_equals(test.name, 'Fail')
     assert_equals(test.doc, 'FAIL Expected failure')
     assert_equals(list(test.tags), ['fail', 'force'])
     assert_equals(test.timeout, None)
     assert_equals(test.template, None)
 def test_test_setup_and_teardown(self):
     kws = build('setups_and_teardowns.robot').tests[0].keywords
     assert_keyword(kws.setup, name='Test Setup', type='setup')
     assert_keyword(kws.teardown, name='Test Teardown', type='teardown')
     assert_equals([kw.name for kw in kws],
                   ['Test Setup', 'Keyword', 'Test Teardown'])
     assert_equals([kw.name for kw in kws.normal], ['Keyword'])
 def test_custom_stdout_and_stderr_with_minimal_implementation(self):
     output = StreamWithOnlyWriteAndFlush()
     assert_equals(run_without_outputs(self.warn, stdout=output, stderr=output), 0)
     self._assert_output(output, [('[ WARN ]', 4), ('[ ERROR ]', 1),
                                  ('Warnings And Errors', 3), ('Output:', 1),
                                  ('Log:', 0), ('Report:', 0)])
     self._assert_outputs()
 def test_from_test_case(self):
     test = build('../running/test_template.robot').tests[3]
     kws = test.keywords
     assert_keyword(kws[0], (), 'Should Not Be Equal', ('Same', 'Same'))
     assert_keyword(kws[1], (), 'Should Not Be Equal', ('42', '43'))
     assert_keyword(kws[2], (), 'Should Not Be Equal', ('Something', 'Different'))
     assert_equals(test.template, 'Should Not Be Equal')
Beispiel #14
0
 def test_list_variable_item_info_when_value_none(self):
     name = "@{foo}"
     source = "source"
     value = None
     info = VariableInfo(name, value, source)
     assert_equals(info.name, name)
     assert_in_details(info, source, "")
 def test_original_signal_handlers_are_restored(self):
     my_sigterm = lambda signum, frame: None
     signal.signal(signal.SIGTERM, my_sigterm)
     run(join(ROOT, 'atest', 'testdata', 'misc', 'pass_and_fail.txt'),
         stdout=StringIO(), output=None, log=None, report=None)
     assert_equals(signal.getsignal(signal.SIGINT), self.orig_sigint)
     assert_equals(signal.getsignal(signal.SIGTERM), my_sigterm)
Beispiel #16
0
 def test_variable_item_info(self):
     name = "${foo}"
     source = "source"
     value = True
     info = VariableInfo(name, value, source)
     assert_equals(info.name, name)
     assert_in_details(info, source, "True")
Beispiel #17
0
 def test_list_variable_item_info(self):
     name = "@{foo}"
     source = "source"
     value = [1, 2, 3]
     info = VariableInfo(name, value, source)
     assert_equals(info.name, name)
     assert_in_details(info, source, "[ 1 | 2 | 3 ]")
 def test_cached_messages_are_given_to_registered_writers(self):
     self.logger.write('This is a cached message', 'INFO')
     self.logger.write('Another cached message', 'TRACE')
     logger = LoggerMock(('This is a cached message', 'INFO'),
                         ('Another cached message', 'TRACE'))
     self.logger.register_logger(logger)
     assert_equals(logger.msg.message, 'Another cached message')
 def test_keys_values_and_items_are_returned_in_same_order(self):
     nd = NormalizedDict()
     for i, c in enumerate('abcdefghijklmnopqrstuvwxyz0123456789!"#%&/()=?'):
         nd[c.upper()] = i
         nd[c+str(i)] = 1
     assert_equals(nd.items(), zip(nd.keys(), nd.values()))
     assert_equals(list(nd.iteritems()), zip(nd.iterkeys(), nd.itervalues()))
Beispiel #20
0
    def test_set_editable_value(self):
        test_text = '''My doc
 with enters
 and \t tabs'''
        self.ctrl.editable_value = test_text
        assert_equals(self.doc.value, 'My doc\\n with enters\\n and \t tabs')
        assert_equals(self.ctrl.editable_value, test_text)
 def test_all_methods(self):
     logger = LoggerMock2(('Hello, world!', 'INFO'))
     self.logger.register_logger(logger)
     self.logger.output_file('name', 'path')
     self.logger.close()
     assert_equals(logger.output_file, ('name', 'path'))
     assert_true(logger.closed)
 def test_structure(self):
     error = self._failing_import('NoneExisting')
     message = ("Importing 'NoneExisting' failed: ImportError: No module "
                "named {q}NoneExisting{q}".format(q="'" if PY3 else ""))
     expected = (message, self._get_traceback(error),
                 self._get_pythonpath(error), self._get_classpath(error))
     assert_equals(unicode(error), '\n'.join(expected).strip())
Beispiel #23
0
 def test_broken_listener(self):
     self.plugin.subscribe(self.plugin.error_listener, RideLog)
     RideTestMessage().publish()
     assert_true(self.plugin.error.message.startswith('Error in listener: ride.test'),
                 'Wrong error message text: ' + self.plugin.error.message)
     assert_equals(self.plugin.error.topic, 'ride.log.exception')
     assert_equals(self.plugin.error.level, 'ERROR')
Beispiel #24
0
 def test_non_existing_absolute_paths_are_not_normalized(self):
     cache = ImportCache()
     path = join(abspath('.'), '.', 'NonExisting.file')
     value = object()
     cache[path] = value
     assert_equals(cache[path], value)
     assert_equals(cache._keys[0], path)
 def test_listener_unregistration(self):
     listener = join(ROOT, 'utest', 'resources', 'Listener.py')
     assert_equals(run_without_outputs(self.data, listener=listener+':1'), 0)
     self._assert_outputs([("[from listener 1]", 1), ("[listener close]", 1)])
     self._clear_outputs()
     assert_equals(run_without_outputs(self.data), 0)
     self._assert_outputs([("[from listener 1]", 0), ("[listener close]", 0)])
Beispiel #26
0
 def test_existing_absolute_paths_are_normalized(self):
     cache = ImportCache()
     path = join(abspath('.'), '.', os.listdir('.')[0])
     value = object()
     cache[path] = value
     assert_equals(cache[path], value)
     assert_equals(cache._keys[0], normpath(path))
Beispiel #27
0
 def test_existing_non_absolute_paths_are_not_normalized(self):
     cache = ImportCache()
     path = os.listdir('.')[0]
     value = object()
     cache[path] = value
     assert_equals(cache[path], value)
     assert_equals(cache._keys[0], path)
 def test_warning_linking(self):
     msg = Message("Message", "WARN", timestamp="20111204 22:04:03.210", parent=TestCase().keywords.create())
     self._verify_message(msg, "Message", 3, 0)
     links = self.context._msg_links
     assert_equals(len(links), 1)
     key = (msg.message, msg.level, msg.timestamp)
     assert_equals(remap(links[key], self.context.strings), "t1-k1")
Beispiel #29
0
 def test_unicode_nfc_and_nfd_decomposition_equality(self):
     import unicodedata
     text = u'Hyv\xe4'
     assert_equals(unic(unicodedata.normalize('NFC', text)), text)
     # In Mac filesystem umlaut characters are presented in NFD-format.
     # This is to check that unic normalizes all strings to NFC
     assert_equals(unic(unicodedata.normalize('NFD', text)), text)
 def test_remove_unused_strings_nested(self):
     strings = tuple(' abcde')
     model = (StringIndex(0), StringIndex(1), 2, 3, StringIndex(4), 5,
              (0, StringIndex(1), 2, StringIndex(3), 4, 5))
     model, strings = _KeywordRemover().remove_unused_strings(model, strings)
     assert_equals(strings, tuple(' acd'))
     assert_equals(model, (0, 1, 2, 3, 3, 5, (0, 1, 2, 2, 4, 5)))
Beispiel #31
0
 def test_java_strings_are_not_list_like(self):
     assert_equals(is_list_like(String()), False)
Beispiel #32
0
 def test_others(self):
     for thing in [1, None, True, object(), [], (), {}]:
         assert_equals(is_str_like(thing), False, thing)
Beispiel #33
0
 def test_string_likes(self):
     for thing in ['', 'a', u'\xe4', UserString('us'), MutableString('ms')]:
         assert_equals(is_str_like(thing), True, thing)
Beispiel #34
0
 def test_others(self):
     for thing in ['', u'', 1, None, True, object(), [], (), set()]:
         assert_equals(is_dict_like(thing), False, thing)
Beispiel #35
0
 def test_dict_likes(self):
     for thing in [dict(), UserDict(), MyMapping()]:
         assert_equals(is_dict_like(thing), True, thing)
Beispiel #36
0
 def test_others_are_not_list_like(self):
     for thing in [1, None, True, object()]:
         assert_equals(is_list_like(thing), False, thing)
Beispiel #37
0
 def test_java_dict_likes_are_not_list_like(self):
     assert_equals(is_list_like(HashMap()), False)
Beispiel #38
0
 def test_strings_are_not_list_like(self):
     for thing in ['str', u'unicode', UserString('user')]:
         assert_equals(is_list_like(thing), False, thing)
Beispiel #39
0
 def _verify(self, stdout='', stderr=''):
     assert_equals(self.stdout.text, stdout)
     assert_equals(self.stderr.text, stderr)
Beispiel #40
0
 def test_dict_likes_are_not_list_like(self):
     for thing in [dict(), UserDict(), MyMapping()]:
         assert_equals(is_list_like(thing), False, thing)
 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 _write_results(self, **settings):
     result = self._get_execution_result()
     settings = StubSettings(**settings)
     rc = ResultWriter(result).write_results(settings)
     assert_equals(rc, 1)
 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_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 _assert_resource_dir_contains_resources(self):
     assert_equals(self.chief.data.children[0].children, self.chief.resources)
 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_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_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_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 _assert_resource_dir_was_created_as_child_of(self, ctrl):
     assert_equals(len(ctrl.children), 1)
 def test_datafiles_property_with_resource_file_only(self):
     resource = self.ctrl.load_resource(RESOURCE_PATH, self.load_observer)
     assert_equals(self.ctrl.datafiles[0], resource)
 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_with_same_path_is_not_added_twice(self):
     self.ctrl.new_resource('somepath')
     self.ctrl.new_resource('somepath')
     assert_equals(len(self.ctrl.resources), 1)
 def test_get_all_keywords_with_resource_file_only(self):
     chief = datafilereader.construct_chief_controller(RESOURCE_PATH)
     all_kws = chief.get_all_keywords()
     chief.close()
     res_kws = [kw for kw in all_kws if kw.name == 'Resource UK']
     assert_equals(len(res_kws), 1)
 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_sort_external_resources(self):
     self.ctrl.load_data(EXTERNAL_RES_UNSORTED_PATH, MessageRecordingLoadObserver())
     assert_equals([res.name for res in self.ctrl.external_resources], ["Abc", "Bar", "Foo", "Hello", "Resource"])
 def _assert_format(self, expected, source, format=''):
     data = TestCaseFile(source=source)
     ctx = WritingContext(data, format=format)
     assert_equals(ctx.format, expected)
 def test_creating_new_resource(self):
     controller = self.ctrl.new_resource('somepath')
     assert_equals(controller.name, 'Somepath')
 def _assert_output_file(self, expected, source=None, format=''):
     ctx = WritingContext(TestCaseFile(source=source), format=format)
     assert_equals(ctx._output_path(), expected)
Beispiel #60
0
 def _test_rows_are_not_split_if_there_are_headers(self, format='txt'):
     output = self._add_long_step_and_save(format)
     assert_equals(len(output.splitlines()), 3)