File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -68,14 +68,6 @@ def test_code_block(self):
6868'ijkl'
6969 """ )
7070 self .assertEqual (result ['code' ], expected_code .strip ())
71-
72- # 验证清理后的文本
73- expected_text = """
74- I have the following string:
75- How can I get the last four characters and store them in a string using Python?
76- Like this:
77- """
78- self .assertEqual (result ['text' ], text )
7971 self .assertEqual (result ['formula' ], '' )
8072
8173 # def test_code_with_leading_trailing_spaces(self):
@@ -92,5 +84,28 @@ def test_code_block(self):
9284 # self.assertEqual(result['code'], '') # 不应该匹配多行行内代码
9385 # self.assertEqual(result['text'], text) # 原样保留
9486
87+ def test_indent_code_block (self ):
88+ """测试代码块"""
89+ text = """
90+ I have the following string: `"aaaabbbb"`
91+ How can I get the last four characters and store them in a string using Python?
92+ Like this:
93+
94+ print("hello world")
95+ print("hi")
96+
97+ """
98+
99+ result = BaseMetric ._extract_from_markdown (text )
100+
101+ # 验证提取的代码
102+ expected_code = ("""
103+ print("hello world")
104+ print("hi")
105+ """ )
106+ self .assertEqual (result ['code' ], expected_code .strip ())
107+ self .assertEqual (result ['formula' ], '' )
108+
109+
95110if __name__ == '__main__' :
96111 unittest .main ()
You can’t perform that action at this time.
0 commit comments