Exemple #1
0
 def test_includes_diff_of_coerced_arguments(self):
     expected = "A tuple", "that differs", "here."
     observed = "A tuple", "that differs", "HERE."
     mismatch = TextEquals(expected).match(observed)
     details = mismatch.get_details()
     self.assertThat(details, ContainsDict({"diff": IsInstance(Content)}))
     self.assertThat(details["diff"].as_text(), Equals(dedent("""\
     --- expected
     +++ observed
     - ('A tuple', 'that differs', 'here.')
     ?                              ^^^^
     + ('A tuple', 'that differs', 'HERE.')
     ?                              ^^^^
     """)))
Exemple #2
0
 def test_includes_diff_of_mismatch(self):
     expected = "A line of text that differs at the end."
     observed = "A line of text that differs at THE end."
     mismatch = TextEquals(expected).match(observed)
     details = mismatch.get_details()
     self.assertThat(details, ContainsDict({"diff": IsInstance(Content)}))
     self.assertThat(details["diff"].as_text(), Equals(dedent("""\
     --- expected
     +++ observed
     - A line of text that differs at the end.
     ?                                ^^^
     + A line of text that differs at THE end.
     ?                                ^^^
     """)))
Exemple #3
0
 def test_includes_diff_of_mismatch_multiple_lines(self):
     expected = "A line of text that differs\nat the end of the 2nd line."
     observed = "A line of text that differs\nat the end of the 2ND line."
     mismatch = TextEquals(expected).match(observed)
     details = mismatch.get_details()
     self.assertThat(details, ContainsDict({"diff": IsInstance(Content)}))
     self.assertThat(details["diff"].as_text(), Equals(dedent("""\
     --- expected
     +++ observed
       A line of text that differs
     - at the end of the 2nd line.
     ?                    ^^
     + at the end of the 2ND line.
     ?                    ^^
     """)))
Exemple #4
0
 def test_describes_mismatch(self):
     self.assertMismatch(
         TextEquals("foo").match("bar"),
         "Observed text does not match expectations; see diff.",
     )
Exemple #5
0
 def test_matches_equal_things(self):
     contents = object()
     self.assertThat(contents, TextEquals(contents))
Exemple #6
0
 def test_matches_equal_strings(self):
     contents = factory.make_string()
     self.assertThat(contents, TextEquals(contents))