def test_matches_distribution_with_custom_matchers(self): metric_result = _create_metric_result(EVERYTHING_DISTRIBUTION) matcher = is_not( MetricResultMatcher( namespace=equal_to_ignoring_case('MYNAMESPACE'), name=equal_to_ignoring_case('MYNAME'), step=equal_to_ignoring_case('MYSTEP'), labels={ equal_to_ignoring_case('PCOLLECTION'): equal_to_ignoring_case('MYCUSTOMVALUE'), 'myCustomKey': equal_to_ignoring_case('MYCUSTOMVALUE') }, committed=is_not( DistributionMatcher(sum_value=greater_than(-1), count_value=greater_than(-1), min_value=greater_than(-1), max_value=greater_than(-1))), attempted=is_not( DistributionMatcher(sum_value=greater_than(-1), count_value=greater_than(-1), min_value=greater_than(-1), max_value=greater_than(-1))), )) hc_assert_that(metric_result, matcher)
def test_matches_distribution_with_custom_matchers(self): metric_result = _create_metric_result(EVERYTHING_DISTRIBUTION) matcher = is_not(MetricResultMatcher( namespace=equal_to_ignoring_case('MYNAMESPACE'), name=equal_to_ignoring_case('MYNAME'), step=equal_to_ignoring_case('MYSTEP'), labels={ equal_to_ignoring_case('PCOLLECTION') : equal_to_ignoring_case('MYCUSTOMVALUE'), 'myCustomKey': equal_to_ignoring_case('MYCUSTOMVALUE') }, committed=is_not(DistributionMatcher( sum_value=greater_than(-1), count_value=greater_than(-1), min_value=greater_than(-1), max_value=greater_than(-1) )), attempted=is_not(DistributionMatcher( sum_value=greater_than(-1), count_value=greater_than(-1), min_value=greater_than(-1), max_value=greater_than(-1) )), )) hc_assert_that(metric_result, matcher)
def test_matches_counter_with_custom_matchers(self): metric_result = _create_metric_result(EVERYTHING_COUNTER) matcher = is_not(MetricResultMatcher( namespace=equal_to_ignoring_case('MYNAMESPACE'), name=equal_to_ignoring_case('MYNAME'), step=equal_to_ignoring_case('MYSTEP'), labels={ equal_to_ignoring_case('PCOLLECTION') : equal_to_ignoring_case('MYCUSTOMVALUE'), 'myCustomKey': equal_to_ignoring_case('MYCUSTOMVALUE') }, committed=greater_than(0), attempted=greater_than(0) )) hc_assert_that(metric_result, matcher)
def test_matches_counter_with_custom_matchers(self): metric_result = _create_metric_result(EVERYTHING_COUNTER) matcher = is_not( MetricResultMatcher( namespace=equal_to_ignoring_case('MYNAMESPACE'), name=equal_to_ignoring_case('MYNAME'), step=equal_to_ignoring_case('MYSTEP'), labels={ equal_to_ignoring_case('PCOLLECTION'): equal_to_ignoring_case('MYCUSTOMVALUE'), 'myCustomKey': equal_to_ignoring_case('MYCUSTOMVALUE') }, committed=greater_than(0), attempted=greater_than(0))) hc_assert_that(metric_result, matcher)
def testCanApplyUnicodeStringToPlainMatcher(self): self.assert_matches('ascii-unicode', equal_to_ignoring_case('heLLo'), u'HelLo')
def testCanApplyPlainStringToUnicodeMatcher(self): self.assert_matches('unicode-ascii', equal_to_ignoring_case(u'heLLo'), 'HelLo')
def testCanApplyUnicodeStringToUnicodeMatcher(self): self.assert_matches('unicode-unicode', equal_to_ignoring_case(u'heLLo'), u'HelLo')
if __name__ == '__main__': import sys sys.path.insert(0, '..') sys.path.insert(0, '../..') from hamcrest.library.text.isequal_ignoring_case import equal_to_ignoring_case from hamcrest_unit_test.matcher_test import MatcherTest import unittest __author__ = "Jon Reid" __copyright__ = "Copyright 2011 hamcrest.org" __license__ = "BSD, see License.txt" matcher = equal_to_ignoring_case('heLLo') class IsEqualIgnoringCaseTest(MatcherTest): def testIgnoresCaseOfCharsInString(self): self.assert_matches('all upper', matcher, 'HELLO') self.assert_matches('all lower', matcher, 'hello') self.assert_matches('mixed up', matcher, 'HelLo') self.assert_does_not_match('no match', matcher, 'bye') def testFailsIfAdditionalWhitespaceIsPresent(self): self.assert_does_not_match('whitespace suffix', matcher, 'heLLo ') self.assert_does_not_match('whitespace prefix', matcher, ' heLLo') def testMatcherCreationRequiresString(self): self.assertRaises(TypeError, equal_to_ignoring_case, 3)
def test_equal_to_ignoring_case_matcher(self): self.spy.one_arg_method('hello') assert_that_was_called(self.spy.one_arg_method).with_args( equal_to_ignoring_case('HEllO'))
def testCanApplyUnicodeStringToPlainMatcher(self): self.assert_matches('ascii-unicode', equal_to_ignoring_case('heLLo'), six.u('HelLo'))
def testCanApplyPlainStringToUnicodeMatcher(self): self.assert_matches('unicode-ascii', equal_to_ignoring_case(six.u('heLLo')), 'HelLo')
def testCanApplyUnicodeStringToUnicodeMatcher(self): self.assert_matches('unicode-unicode', equal_to_ignoring_case(six.u('heLLo')), six.u('HelLo'))
import six from hamcrest.library.text.isequal_ignoring_case import equal_to_ignoring_case from hamcrest_unit_test.matcher_test import MatcherTest import unittest __author__ = "Jon Reid" __copyright__ = "Copyright 2011 hamcrest.org" __license__ = "BSD, see License.txt" matcher = equal_to_ignoring_case('heLLo') class IsEqualIgnoringCaseTest(MatcherTest): def testIgnoresCaseOfCharsInString(self): self.assert_matches('all upper', matcher, 'HELLO') self.assert_matches('all lower', matcher, 'hello') self.assert_matches('mixed up', matcher, 'HelLo') self.assert_does_not_match('no match', matcher, 'bye') def testFailsIfAdditionalWhitespaceIsPresent(self): self.assert_does_not_match('whitespace suffix', matcher, 'heLLo ') self.assert_does_not_match('whitespace prefix', matcher, ' heLLo') def testMatcherCreationRequiresString(self): self.assertRaises(TypeError, equal_to_ignoring_case, 3) def testFailsIfMatchingAgainstNonString(self): self.assert_does_not_match('non-string', matcher, object())
import unittest from hamcrest.library.text.isequal_ignoring_case import equal_to_ignoring_case from hamcrest_unit_test.matcher_test import MatcherTest __author__ = "Jon Reid" __copyright__ = "Copyright 2011 hamcrest.org" __license__ = "BSD, see License.txt" matcher = equal_to_ignoring_case("heLLo") class IsEqualIgnoringCaseTest(MatcherTest): def testIgnoresCaseOfCharsInString(self): self.assert_matches("all upper", matcher, "HELLO") self.assert_matches("all lower", matcher, "hello") self.assert_matches("mixed up", matcher, "HelLo") self.assert_does_not_match("no match", matcher, "bye") def testFailsIfAdditionalWhitespaceIsPresent(self): self.assert_does_not_match("whitespace suffix", matcher, "heLLo ") self.assert_does_not_match("whitespace prefix", matcher, " heLLo") def testMatcherCreationRequiresString(self): self.assertRaises(TypeError, equal_to_ignoring_case, 3) def testFailsIfMatchingAgainstNonString(self): self.assert_does_not_match("non-string", matcher, object()) def testHasAReadableDescription(self):
def test_equal_to_ignoring_case_matcher(self): self.spy.one_arg_method('hello') assert_that_was_called(self.spy.one_arg_method).with_args( equal_to_ignoring_case('HEllO'))