浏览代码

test_doctest()

tags/v0.2
Ben Kurtovic 11 年前
父节点
当前提交
fe3328aa38
共有 2 个文件被更改,包括 11 次插入1 次删除
  1. +1
    -1
      mwparserfromhell/smart_list.py
  2. +10
    -0
      tests/test_smart_list.py

+ 1
- 1
mwparserfromhell/smart_list.py 查看文件

@@ -363,4 +363,4 @@ class _ListProxy(list):
self._parent[self._start:self._stop:self._step] = item


del inheritdoc
del inheritdoc

+ 10
- 0
tests/test_smart_list.py 查看文件

@@ -38,5 +38,15 @@ class TestSmartList(unittest.TestCase):
self.assertEquals(expected, smartlist_doc)
self.assertEquals(expected, listproxy_doc)

def test_doctest(self):
"""make sure a test embedded in SmartList's docstring passes"""
parent = SmartList([0, 1, 2, 3])
self.assertEquals([0, 1, 2, 3], parent)
child = parent[2:]
self.assertEquals([2, 3], child)
child.append(4)
self.assertEquals([2, 3, 4], child)
self.assertEquals([0, 1, 2, 3, 4], parent)

if __name__ == "__main__":
unittest.main(verbosity=2)

正在加载...
取消
保存