diff options
author | 2017-02-01 10:32:53 -0800 | |
---|---|---|
committer | 2017-02-01 10:48:06 -0800 | |
commit | 43af740fcbe161845f4f046e8e1699f2ffb51eaa (patch) | |
tree | fc6699402bb3338ff773274001889c7bb03696e2 | |
parent | eef537ce8dbbca0b005565146f26873d75c6e234 (diff) |
tfdbg CLI: fix a bug RichTextLines.prepend that caused font_attr_segs to be None
Change: 146260296
-rw-r--r-- | tensorflow/python/debug/cli/debugger_cli_common.py | 4 | ||||
-rw-r--r-- | tensorflow/python/debug/cli/debugger_cli_common_test.py | 16 |
2 files changed, 19 insertions, 1 deletions
diff --git a/tensorflow/python/debug/cli/debugger_cli_common.py b/tensorflow/python/debug/cli/debugger_cli_common.py index 4069ca7d5e..b6b783fcfd 100644 --- a/tensorflow/python/debug/cli/debugger_cli_common.py +++ b/tensorflow/python/debug/cli/debugger_cli_common.py @@ -247,7 +247,9 @@ class RichTextLines(object): line. """ - other = RichTextLines(line, font_attr_segs={0: font_attr_segs}) + other = RichTextLines(line) + if font_attr_segs: + other.font_attr_segs[0] = font_attr_segs self._extend_before(other) def write_to_file(self, file_path): diff --git a/tensorflow/python/debug/cli/debugger_cli_common_test.py b/tensorflow/python/debug/cli/debugger_cli_common_test.py index fbcc9afe09..e60e05c481 100644 --- a/tensorflow/python/debug/cli/debugger_cli_common_test.py +++ b/tensorflow/python/debug/cli/debugger_cli_common_test.py @@ -606,6 +606,22 @@ class RegexFindTest(test_util.TensorFlowTestCase): with self.assertRaisesRegexp(ValueError, "Invalid regular expression"): debugger_cli_common.regex_find(self._orig_screen_output, "[", "yellow") + def testRegexFindOnPrependedLinesWorks(self): + rich_lines = debugger_cli_common.RichTextLines(["Violets are blue"]) + rich_lines.prepend(["Roses are red"]) + searched_rich_lines = debugger_cli_common.regex_find( + rich_lines, "red", "bold") + self.assertEqual( + {0: [(10, 13, "bold")]}, searched_rich_lines.font_attr_segs) + + rich_lines = debugger_cli_common.RichTextLines(["Violets are blue"]) + rich_lines.prepend(["A poem"], font_attr_segs=[(0, 1, "underline")]) + searched_rich_lines = debugger_cli_common.regex_find( + rich_lines, "poem", "italic") + self.assertEqual( + {0: [(0, 1, "underline"), (2, 6, "italic")]}, + searched_rich_lines.font_attr_segs) + class WrapScreenOutputTest(test_util.TensorFlowTestCase): |