欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

'module' object has no attribute

程序员文章站 2022-07-13 10:51:42
...

-- coding: utf-8 --

import unittest
from name_function import get_formatted_name

class NamesTestCase(unittest.TestCase):
“”“测试name_function.py”""

def test_first_last_name(self):
    """能够正确地处理像Janis Joplin这样的姓名吗?"""
    formatted_name = get_formatted_name('Janis','Joplin')
    self.assertEqual(formatted_name,'Janis Joplin')

unittest.main()
Traceback (most recent call last):
File “C:\Program Files (x86)\JetBrains\PyCharm Edu 3.5\helpers\pycharm\utrunner.py”, line 153, in
modules = [loadSource(a[0])]
File “C:\Program Files (x86)\JetBrains\PyCharm Edu 3.5\helpers\pycharm\utrunner.py”, line 65, in loadSource
module = imp.load_source(moduleName, fileName)
File “F:\Program Files (x86)\mcpipy\ceshiyongli.py”, line 13, in
unittest.main()
File “C:\Python27\lib\unittest\main.py”, line 94, in init
self.parseArgs(argv)
File “C:\Python27\lib\unittest\main.py”, line 149, in parseArgs
self.createTests()
File “C:\Python27\lib\unittest\main.py”, line 158, in createTests
self.module)
File “C:\Python27\lib\unittest\loader.py”, line 130, in loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name in names]
File “C:\Python27\lib\unittest\loader.py”, line 100, in loadTestsFromName
parent, obj = obj, getattr(obj, part)
AttributeError: ‘module’ object has no attribute ‘F:\Program Files (x86)\mcpipy\ceshiyongli’
Process finished with exit code 1
请问大神改如何解决?