使用Unittest模块导入问题

时间:2015-10-21 15:21:32

标签: python python-3.x python-import python-unittest

我正在尝试使用unittest模块,以便我可以更熟悉运行测试的过程,但是在另一个文件上运行测试时遇到错误。我在下一行收到了无效的语法错误,

from AccuAdmin2.0 import format_filename

显然它不喜欢0。如果不重命名我的文件,我该如何解决这个问题呢?

我的代码:

import unittest
from AccuAdmin2.0 import format_filename

class TestMyFunctions(unittest.TestCase):
    def testSomething(self):
        self.assertTrue(format_filename("fehfihehe_efeaf")) 

以下是整个错误:

Traceback (most recent call last):
  File "/Applications/PyCharm CE.app/Contents/helpers/pycharm/utrunner.py", line 120, in <module>
    modules = [loadSource(a[0])]
  File "/Applications/PyCharm CE.app/Contents/helpers/pycharm/utrunner.py", line 41, in loadSource
    module = imp.load_source(moduleName, fileName)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/imp.py", line 171, in load_source
    module = methods.load()
  File "<frozen importlib._bootstrap>", line 1220, in load
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1467, in exec_module
  File "<frozen importlib._bootstrap>", line 1572, in get_code
  File "<frozen importlib._bootstrap>", line 1532, in source_to_code
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/Users/accudeveloper/PycharmProjects/AccuAdmin2.0/AccuAdmin2.0 UnitTests.py", line 3
    from AccuAdmin2.0 import format_filename
                    ^
SyntaxError: invalid syntax

0 个答案:

没有答案