MCPcopy Create free account
hub / github.com/boostorg/build / __expect_lines

Method __expect_lines

v2/test/BoostBuild.py:892–952  ·  view source on GitHub ↗

Checks whether the given data contains the given lines. Data may be specified as a single string containing text lines separated by newline characters. Lines may be specified in any of the following forms: * Single string containing text lines sep

(self, data, lines, expected)

Source from the content-addressed store, hash-verified

890 self.__wait_for_time_change(path, touch=True, last_build_time=True)
891
892 def __expect_lines(self, data, lines, expected):
893 """
894 Checks whether the given data contains the given lines.
895
896 Data may be specified as a single string containing text lines
897 separated by newline characters.
898
899 Lines may be specified in any of the following forms:
900 * Single string containing text lines separated by newlines - the
901 given lines are searched for in the given data without any extra
902 data lines between them.
903 * Container of strings containing text lines separated by newlines
904 - the given lines are searched for in the given data with extra
905 data lines allowed between lines belonging to different strings.
906 * Container of strings containing text lines separated by newlines
907 and containers containing strings - the same as above with the
908 internal containers containing strings being interpreted as if
909 all their content was joined together into a single string
910 separated by newlines.
911
912 A newline at the end of any multi-line lines string is interpreted as
913 an expected extra trailig empty line.
914 """
915 # str.splitlines() trims at most one trailing newline while we want the
916 # trailing newline to indicate that there should be an extra empty line
917 # at the end.
918 splitlines = lambda x : (x + "\n").splitlines()
919
920 if data is None:
921 data = []
922 elif data.__class__ is str:
923 data = splitlines(data)
924
925 if lines.__class__ is str:
926 lines = [splitlines(lines)]
927 else:
928 expanded = []
929 for x in lines:
930 if x.__class__ is str:
931 x = splitlines(x)
932 expanded.append(x)
933 lines = expanded
934
935 if _contains_lines(data, lines) != bool(expected):
936 output = []
937 if expected:
938 output = ["Did not find expected lines:"]
939 else:
940 output = ["Found unexpected lines:"]
941 first = True
942 for line_sequence in lines:
943 if line_sequence:
944 if first:
945 first = False
946 else:
947 output.append("...")
948 output.extend(" > " + line for line in line_sequence)
949 output.append("in output:")

Callers 2

expect_output_linesMethod · 0.95
expect_content_linesMethod · 0.95

Calls 4

fail_testMethod · 0.95
_contains_linesFunction · 0.85
annotationFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected