当前位置: 首页>>代码示例>>Python>>正文


Python Commons.chunk_string_dot方法代码示例

本文整理汇总了Python中inc.Commons.Commons.chunk_string_dot方法的典型用法代码示例。如果您正苦于以下问题:Python Commons.chunk_string_dot方法的具体用法?Python Commons.chunk_string_dot怎么用?Python Commons.chunk_string_dot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在inc.Commons.Commons的用法示例。


在下文中一共展示了Commons.chunk_string_dot方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_chunk_string_dot

# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import chunk_string_dot [as 别名]
 def test_chunk_string_dot(self):
     string1 = "a"*50
     chunks1 = Commons.chunk_string_dot(string1, 100)
     assert len(chunks1) == 1, "Should only be one chunk when splitting " + string1
     assert chunks1[0] == string1, "Should not have changed string " + string1
     string2 = "a"*100
     chunks2 = Commons.chunk_string_dot(string2, 100)
     assert len(chunks2) == 1, "Should only be one chunk when splitting " + string2
     assert chunks2[0] == string2, "Should not have changed string " + string2
     string3 = "a"*101
     chunks3 = Commons.chunk_string_dot(string3, 100)
     assert len(chunks3) == 2, "Should have split string into 2 chunks: " + string3
     assert len(chunks3[0]) == 100, "First chunk should be exactly 100 characters " + chunks3[0]
     assert chunks3[0] == "a"*97+"...", "First chunk of string was not created correctly"
     assert chunks3[1] == "..."+"a"*(101-97), "Second chunk of string was not created correctly."
     string4 = "a"*97*2
     chunks4 = Commons.chunk_string_dot(string4, 100)
     assert len(chunks4) == 2, "Should have split string into just 2 chunks."
     assert len(chunks4[0]) == 100, "First chunk should be exactly 100 characters"
     assert len(chunks4[1]) == 100, "Second chunk should be exactly 100 characters"
     assert chunks4[0] == "a"*97+"...", "First chunk of string was not created correctly"
     assert chunks4[1] == "..."+"a"*97, "Second chunk of string was not created correctly."
     string5 = "a"*(97*3-3)
     chunks5 = Commons.chunk_string_dot(string5, 100)
     assert len(chunks5) == 3, "Should have split string into 3 chunks"
     assert len(chunks5[0]) == 100, "First chunk should be 100 characters"
     assert len(chunks5[1]) == 100, "Second chunk should be 100 characters"
     assert len(chunks5[2]) == 100, "Third chunk should be 100 characters"
     assert chunks5[0] == "a"*97+"...", "First chunk created incorrectly."
     assert chunks5[1] == "..."+"a"*94+"...", "Second chunk created incorrectly."
     assert chunks5[2] == "..."+"a"*97, "Third chunk created incorrectly."
     string6 = "a"*(97*3-2)
     chunks6 = Commons.chunk_string_dot(string6, 100)
     assert len(chunks6) == 4, "Should have split string into 4 chunks"
     assert len(chunks6[0]) == 100, "First chunk should be 100 characters"
     assert len(chunks6[1]) == 100, "Second chunk should be 100 characters"
     assert len(chunks6[2]) == 100, "Third chunk should be 100 characters"
     assert chunks6[0] == "a"*97+"...", "First chunk created incorrectly"
     assert chunks6[1] == "..." + "a" * 94 + "...", "Second chunk created incorrectly"
     assert chunks6[2] == "..." + "a" * 94 + "...", "Third chunk created incorrectly"
     assert chunks6[3] == "..."+"a"*((97*3-2)-(94+94+97)), "Forth chunk created incorrectly"
开发者ID:joshcoales,项目名称:Hallo,代码行数:43,代码来源:testCommons.py


注:本文中的inc.Commons.Commons.chunk_string_dot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。