KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am using pycharm at one of my university projects and I wanted to integrated it with unittest module, but I have a problem with structuring my project Part of this project involves generating abstract syntax trees, so I created AST directory and put __init__.py there, then I created expression module. I wanted to put my tests in test/ subdirectory, so it would look like this: AST/ __init__.py expression.py test/ some_test.py utils.py now I have also module in my AST called symbol_table and module called utils , example test class looks like import unittest from ...AST import expression from ...AST import utils class ConstantExpressionTest(unittest.TestCase): def testConstantExpressionCheck(self): constantExpression = expression.ConstantExpression(17, 5, utils.TYPES.INT) self.assertTrue(constantExpression.check()) when I right click on this file and select Run Unittest in ... I am getting errors: /usr/bin/python2.7 /home/xubuntu/Downloads/pycharm-2.7.2/helpers/pycharm/utrunner.py /home/xubuntu/Przedmioty/VI/kompilatory/tk-projekt/src/AST/test/test_constant_expression.py true Testing started at 12:06 PM ... Traceback (most recent call last): File "/home/xubuntu/Downloads/pycharm-2.7.2/helpers/pycharm/utrunner.py", line 110, in <module> modules = [loadSource(a[0])] File "/home/xubuntu/Downloads/pycharm-2.7.2/helpers/pycharm/utrunner.py", line 34, in loadSource module = imp.load_source(moduleName, fileName) File "/home/xubuntu/Przedmioty/VI/kompilatory/tk-projekt/src/AST/test/test_constant_expression.py", line 2, in <module> from ...AST import utils ValueError: Attempted relative import in non-package Process finished with exit code 1 I have read about this problem and if I u
Tags (comma-separated)
Save Edits
Cancel