为什么'isInstance'没有定义?

时间:2017-11-09 22:29:21

标签: python-3.x unit-testing

我是一个TOTAL python新手,但我试图在侧面构建一个小的Python实用程序。我已经构建了一个单元测试来测试一个基本的setter,但我的单元测试失败了NameError: name 'isInstance' is not defined

我愚蠢的小实用程序:

from pathlib import Path

class DirectoryStructureNormalizer:

    def __init__(self, path):
        self.path = path

    @property
    def path(self):
        return self.__path

    @path.setter
    def path(self, path):
        self.__path = Path(path)

我的单元测试:

import unittest

from pathlib import Path

from DirectoryStructureNormalizer import DirectoryStructureNormalizer


class DirectoryStructureNormalizerTests(unittest.TestCase):

    def testSetterShouldSetPathToPathlibPath(self):
        directoryStructureNormalizer = DirectoryStructureNormalizer('.')
        self.assertTrue(isInstance(directoryStructureNormalizer.path, Path))

def main():
        unittest.main()

if __name__ == '__main__':
    main()

最后,我的输出:

E
======================================================================
ERROR: testSetterShouldSetPathToPathlibPath (__main__.DirectoryStructureNormalizerTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "DirectoryStructureNormalizerTests.py", line 12, in testSetterShouldSetPathToPathlibPath
    self.assertTrue(isInstance(directoryStructureNormalizer.path, Path))
NameError: name 'isInstance' is not defined

----------------------------------------------------------------------
Ran 1 test in 0.002s

FAILED (errors=1)

我知道我缺少一些超级基本的东西,但是什么?

0 个答案:

没有答案