def test_iteritems_and_items(self): nd = NormalizedDict({"A": 1, "b": 2, "C": 3}) iterator = nd.iteritems() assert_false(isinstance(iterator, list)) assert_equals(list(iterator), [("A", 1), ("b", 2), ("C", 3)]) assert_equals(list(iterator), []) assert_equals(list(nd.iteritems()), nd.items())
def test_has_format(self): ctrl = TestDataDirectoryController(self.data) assert_false(ctrl.has_format()) ctrl.mark_dirty() assert_false(ctrl.has_format()) ctrl.data.initfile = os.path.join('source', '__init__.html') assert_true(ctrl.has_format())
def test_itervalues_and_values(self): nd = NormalizedDict({"A": 1, "b": 3, "C": 2}) iterator = nd.itervalues() assert_false(isinstance(iterator, list)) assert_equals(list(iterator), [1, 3, 2]) assert_equals(list(iterator), []) assert_equals(list(nd.itervalues()), nd.values())
def test_iterkeys_and_keys(self): nd = NormalizedDict({'A': 1, 'b': 3, 'C': 2}) iterator = nd.iterkeys() assert_false(isinstance(iterator, list)) assert_equal(list(iterator), ['A', 'b', 'C']) assert_equal(list(iterator), []) assert_equal(list(nd.iterkeys()), nd.keys())
def test_multiple_nots_with_ors(self): patterns = TagPatterns('a OR b NOT c OR d NOT e OR f') assert_true(patterns.match(['a'])) assert_true(patterns.match(['B'])) assert_false(patterns.match(['c'])) assert_true(all(not patterns.match(['a', 'b', c]) for c in 'cdef')) assert_true(patterns.match(['a', 'x']))
def test_iterkeys_and_keys(self): nd = NormalizedDict({"A": 1, "b": 3, "C": 2}) iterator = nd.iterkeys() assert_false(isinstance(iterator, list)) assert_equals(list(iterator), ["A", "b", "C"]) assert_equals(list(iterator), []) assert_equals(list(nd.iterkeys()), nd.keys())
def test_with_detached_io_buffer(self): with io.StringIO() as stream: wrapper = io.TextIOWrapper(stream, 'UTF-8') wrapper.detach() exc_type = ValueError if PYTHON else AttributeError assert_raises(exc_type, wrapper.isatty) assert_false(isatty(wrapper))
def test_overwrite(self): ctrl = TestCaseFileController(TestCaseFile(source=self._filepath).populate(), ChiefController(Namespace())) os.utime(self._filepath, (1,1)) assert_true(ctrl.has_been_modified_on_disk()) ctrl.save() assert_false(ctrl.has_been_modified_on_disk())
def test_is_variable(self): for no in ['', 'xxx', '${var} not alone', '\\${notvat}', '\\\\${var}', '${var}xx}', '${x}${y}']: assert_false(VariableSplitter(no).is_variable(), no) for yes in ['${var}', '${var${}', '${var${internal}}', '@{var}', '@{var}[0]']: assert_true(VariableSplitter(yes).is_variable(), yes)
def test_empty_cache(self): connections = self._register('a', 'b', 'c', 'd') self.cache.empty_cache() self._verify_initial_state() for conn in connections: assert_false(conn.closed_by_close) assert_false(conn.closed_by_exit)
def test_itervalues_and_values(self): nd = NormalizedDict({'A': 1, 'b': 3, 'C': 2}) iterator = nd.itervalues() assert_false(isinstance(iterator, list)) assert_equal(list(iterator), [1, 3, 2]) assert_equal(list(iterator), []) assert_equal(list(nd.itervalues()), nd.values())
def test_reset(self): sugs = self.ns.get_suggestions_for(self.kw, 'generate random') sugs2 = self.ns.get_suggestions_for(self.kw, 'generate random') assert_true(sugs[0] is sugs2[0]) self.ns.reset_resource_and_library_cache() sugs3 = self.ns.get_suggestions_for(self.kw, 'generate random') assert_false(sugs[0] is sugs3[0])
def test_fatal_error(self): self.errs.start_suite() self.errs.test_failed(exit=True) self.errs.end_suite() self.errs.start_suite() assert_false(self.errs.is_suite_setup_allowed()) assert_false(self.errs.is_suite_setup_allowed())
def test_iteritems_and_items(self): nd = NormalizedDict({'A': 1, 'b': 2, 'C': 3}) iterator = nd.iteritems() assert_false(isinstance(iterator, list)) assert_equal(list(iterator), [('A', 1), ('b', 2), ('C', 3)]) assert_equal(list(iterator), []) assert_equal(list(nd.iteritems()), nd.items())
def test_overwrite(self): ctrl = TestCaseFileController(TestCaseFile(source=self._filepath).populate(), create_project()) os.utime(self._filepath, (1,1)) assert_true(ctrl.has_been_modified_on_disk()) ctrl.execute(SaveFile()) assert_false(ctrl.has_been_modified_on_disk())
def test_other_list_like_items_are_not_touched(self): value = ({'key': 'value'}, [{}]) d = DotDict(key=value) assert_equal(d.key[0]['key'], 'value') assert_false(hasattr(d.key[0], 'key')) assert_true(isinstance(d.key[0], dict)) assert_true(isinstance(d.key[1][0], dict))
def port_should_be_closed(self, port_locator=None): """ Fails if specified port is open. """ asserts.assert_false( self._port(port_locator).is_open, 'Port is open.' )
def port_should_not_have_unsent_bytes(self, port_locator=None): """ Fails if port output buffer contains data. Fails if the port is closed. """ asserts.assert_false( self._port(port_locator).out_waiting, 'Port has out-waiting data.')
def test_resource_getter(self): resources = self.ns.get_resources(self.tcf) assert_equals(len(resources),8) paths = [] for res in resources: normalized = robotpath.normpath(res.source) assert_false(normalized in paths) paths.append(normalized)
def test_multiple_ors(self): patterns = TagPatterns(['xORyORz']) assert_false(patterns.match([])) assert_false(patterns.match(['xxx'])) assert_true(all(patterns.match([c]) for c in 'XYZ')) assert_true(all(patterns.match(['a', 'b', c, 'd']) for c in 'xyz')) assert_true(patterns.match(['x', 'y'])) assert_true(patterns.match(['x', 'Y', 'z']))
def test_items_inserted_outside_init_are_not_converted(self): d = DotDict() d['dict'] = {'key': 'value'} d['list'] = [{}] assert_equal(d.dict['key'], 'value') assert_false(hasattr(d.dict, 'key')) assert_true(isinstance(d.dict, dict)) assert_true(isinstance(d.list[0], dict))
def test_keywords_only_once_per_source(self): sugs = self.ns.get_suggestions_for(self.kw, '') kw_set = [] for kw in sugs: if self._not_variable(kw): key = 'kw: %s %s' % (kw.name, kw.source) assert_false(key in kw_set, key) kw_set.append(key)
def test_passed(self): suite = TestSuite() assert_true(suite.passed) suite.tests.create(status='PASS') assert_true(suite.passed) suite.tests.create(status='FAIL', tags='tag') assert_false(suite.passed) suite.set_criticality(non_critical_tags='tag') assert_true(suite.passed)
def _test_copy_content(self): for setting in self.ctrl.settings: assert_false(setting.is_set, 'not empty %s' % setting.__class__) setting.set_value('boo') setting.set_comment(['hobo']) new = self.ctrl.copy('new name') for setting in new.settings: assert_true(setting.is_set, 'empty %s' % setting.__class__) assert_equals(setting.value, 'boo', 'not boo %s' % setting.__class__) assert_equals(setting.comment.as_list(), ['# hobo'], 'comment not copied %s' % setting.__class__)
def test_or(self): patterns = TagPatterns(['xORy', '???ORz']) assert_false(patterns.match([])) assert_false(patterns.match(['a', 'b', '12', '1234'])) assert_true(patterns.match(['x'])) assert_true(patterns.match(['Y'])) assert_true(patterns.match(['123'])) assert_true(patterns.match(['Z'])) assert_true(patterns.match(['x', 'y', 'z'])) assert_true(patterns.match(['123', 'a', 'b', 'c', 'd'])) assert_true(patterns.match(['a', 'b', 'c', 'd', 'Z']))
def test_unsubscribe_all(self): self.plugin.unsubscribe_all() self._unsubscribe_all = False RideTestMessage().publish() RideMessageWithData(data_item='Data', more_data=[1,2,3]).publish() assert_none(self.plugin.class_handler_topic) assert_none(self.plugin.string_handler_topic) assert_none(self.plugin.case_insensitive_string_handler_topic) assert_equals(self.plugin.record, {}) assert_equals(self.plugin.count, 0) assert_equals(self.plugin.hierarchy_events, []) assert_false(self.plugin in PUBLISHER._listeners)
def test_isatty_with_detached_io_buffer(self): # make sure that isatty() checks for detached io stream buffers # (otherwise it would raise an Exception) with io.StringIO() as stream: wrapper = io.TextIOWrapper(stream) if sys.version_info >= (2, 7): wrapper.detach() #==> wrapper.buffer is None # Jython 2.7 behaves like CPython 2.6 in that case exc_type = ValueError if not JYTHON else AttributeError else: # no .detach and different behaviour if .buffer is None wrapper.buffer = None exc_type = AttributeError assert_raises(exc_type, wrapper.isatty) assert_false(isatty(wrapper))
def test_match_with_multiple_nots_with_ands(self): patterns = TagPatterns('a AND b NOT c AND d NOT e AND f') assert_true(patterns.match(['a', 'b'])) assert_true(patterns.match(['a', 'b', 'c'])) assert_true(patterns.match(['a', 'b', 'c', 'e'])) assert_false(patterns.match(['a', 'b', 'c', 'd'])) assert_false(patterns.match(['a', 'b', 'e', 'f'])) assert_false(patterns.match(['a', 'b', 'c', 'd', 'e', 'f'])) assert_false(patterns.match(['a', 'b', 'c', 'd', 'e']))
def test_assert_false(self): assert_false(False) assert_false('') assert_false([1,2] == (1,2), 'my message') assert_raises(AE, assert_false, True) assert_raises(AE, assert_false, 'non-empty') assert_raises_with_msg(AE, 'message', assert_false, 0 < 1, 'message')
def test_equality(self): assert_true(self.dd == self.dd) assert_false(self.dd != self.dd) assert_true(self.dd == DotDict(self.dd)) assert_false(self.dd != DotDict(self.dd)) assert_false(self.dd == DotDict()) assert_true(self.dd != DotDict())
def _test_copy_empty(self): for setting in self.ctrl.settings: assert_false(setting.is_set, 'not empty %s' % setting.__class__) new = self.ctrl.copy('new name') for setting in new.settings: assert_false(setting.is_set, 'not empty %s' % setting.__class__)
def port_should_be_closed(self, port_locator=None): """ Fails if specified port is open. """ asserts.assert_false(self._port(port_locator).is_open, 'Port is open.')
def test_long_values(self): target = sys.maxint + 42 value = StringIndex(target) assert_equals(str(value), str(target)) assert_false(str(value).endswith('L'))
def test_message_cache_can_be_turned_off(self): self.logger.disable_message_cache() self.logger.write('This message is not cached', 'INFO') logger = LoggerMock(('', '')) self.logger.register_logger(logger) assert_false(hasattr(logger, 'msg'))
def test_eq_with_other_objects(self): nd = NormalizedDict() for other in ['string', 2, None, [], self.test_clear]: assert_false(nd == other, other) assert_true(nd != other, other)
def test_contains(self): items = ItemList(str, items='x') assert_true('x' in items) assert_true('y' not in items) assert_false('x' not in items) assert_false('y' in items)
def test_truth_value(self): assert_false(NormalizedDict()) assert_true(NormalizedDict({'a': 1}))
def test_move_up(self): assert_false(self.ctrl.move_up()) self._assert_uk_in(0, 'UK') assert_true(self.ctrl2.move_up()) self._assert_uk_in(0, 'UK 2')
def test_move_down(self): assert_false(self.ctrl2.move_down()) self._assert_uk_in(1, 'UK 2') assert_true(self.ctrl.move_down()) self._assert_uk_in(1, 'UK')
def test_delete(self): self.ctrl.delete() assert_false('UK' in self.tcf.keyword_table.keywords) self._assert_uk_in(0, 'UK 2')
def test_starting_invalid_table(self): assert_false(self._start_table('Per Se'))
def test_set_timeout(self): self.table.test_timeout.populate(['1s', 'msg', 'in multiple', 'cell']) assert_equal(self.table.test_timeout.value, '1s') assert_equal(self.table.test_timeout.message, 'msg in multiple cell') assert_false(hasattr(self.table.suite_teardown, 'value'))
def test_timeout_default(self): assert_equal(self.table.test_timeout.value, None) assert_equal(self.table.test_timeout.message, '') assert_false(hasattr(self.table.suite_setup, 'value'))
def test_cancel_execute_when_modify_imports_is_canceled(self): self._create_data('fooo.txt', 'fooo.txt') self._verify_import_reference_exists() self._execute_rename_resource('gooo', None) assert_false(self.res_controller.remove_from_filesystem.called) assert_false(self.res_controller.save.called)
def test_timed_out_with_non_exceeded_timeout(self): tout = TestTimeout('10s', variables=VariableMock()) tout.start() time.sleep(0.01) assert_false(tout.timed_out())
def test_keyword_argument_is_not_visible_in_test_cases_local_namespace(self): assert_false(self._test.get_local_namespace().has_name('${argument}'))
def test_comparisons(self): n123 = ItemList(int, items=[1, 2, 3]) n123b = ItemList(int, items=[1, 2, 3]) n1234 = ItemList(int, items=[1, 2, 3, 4]) n124 = ItemList(int, items=[1, 2, 4]) assert_true(n123 == n123b) assert_false(n123 != n123b) assert_true(n123 != n1234) assert_false(n123 == n1234) assert_true(n1234 > n123) assert_true(n1234 >= n123) assert_false(n1234 < n123) assert_false(n1234 <= n123) assert_true(n124 > n123) assert_true(n124 >= n123) assert_false(n124 < n123) assert_false(n124 <= n123) assert_true(n123 >= n123) assert_true(n123 <= n123)
def test_is_user_keyword(self): assert_true(self.ns.is_user_keyword(self.tcf, 'UKFromResource from ResourcewithVariable')) assert_false(self.ns.is_user_keyword(self.tcf, 'hevoinen')) assert_false(self.ns.is_user_keyword(self.tcf, 'Should Be Equal'))
def test_ne(self): assert_false(NormalizedDict() != NormalizedDict()) assert_false(NormalizedDict({'a': 1}) != NormalizedDict({'a': 1})) assert_false(NormalizedDict({'a': 1}) != NormalizedDict({'A': 1}))
def test_is_library_keyword(self): assert_true(self.ns.is_library_keyword(self.tcf, 'Should Be Equal')) assert_false(self.ns.is_library_keyword(self.tcf, 'kameli')) assert_false(self.ns.is_library_keyword(self.tcf, 'UK From Resource from Resource with Variable'))
def test_tokenize_variables_is_generator(self): variables = Token(Token.NAME, 'Hello, ${var}!').tokenize_variables() assert_false(isinstance(variables, list)) assert_equal(iter(variables), variables)
def test_suite(self): assert_equal(self.suite.source, self.source) assert_false(hasattr(self.suite, 'lineno'))
def test_truth(self): assert_true(StringIndex(1)) assert_true(StringIndex(-42)) assert_false(StringIndex(0))
def _setup_and_teardown_disallowed(self): assert_false(self.errs.is_suite_setup_allowed()) assert_false(self.errs.is_suite_teardown_allowed())
def _assert_not_removed(self, path): assert_false(path in self.chief.removed_files)
def _assert_not_serialized(self, path): assert_false(path in self.chief.serialized_files)
def test_fixture_default(self): assert_equal(self.table.suite_setup.name, None) assert_equal(self.table.suite_setup.args, []) assert_false(hasattr(self.table.suite_setup, 'value'))
def test_is_comment(self): assert_true(Step([], comment="comment").is_comment()) assert_false(Step(['KW'], comment="comment").is_comment())
def test_set_fixture(self): self.table.suite_teardown.populate(['Name', 'a1', 'a2']) assert_equal(self.table.suite_teardown.name, 'Name') assert_equal(self.table.suite_teardown.args, ['a1', 'a2']) assert_false(hasattr(self.table.suite_teardown, 'value'))
def test_multiple_excludes(self): assert_false(self._tags123.is_included([], ['incl', 'tag2'])) assert_false(self._tags123.is_included([], ['tag1', 'tag2', 'tag3'])) assert_true( self._tags123.is_included([], ['tag', 'excl', 'not', 'matching']))