Reputation: 14958
I'm trying to port SqlSoup to python 3. I'm using PyCharm as my IDE and I want to run the unit tests.
If I run the unit tests in pycharm I get the following output:
C:\bin\python\python.exe "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0.3\helpers\pycharm\utrunner.py" C:\Users\jdearing\Documents\deleteme\sqlsoup\tests\test_sqlsoup.py true
Testing started at 12:53 PM ...
Error
Traceback (most recent call last):
File "C:\Users\jdearing\Documents\deleteme\sqlsoup\tests\test_sqlsoup.py", line 25, in setUp
engine.execute(sql)
NameError: name 'engine' is not defined
However, if I run the tests from the command line, everything works great:
C:\Users\jdearing\Documents\deleteme\sqlsoup>c:\bin\python\Scripts\nosetests-3.4.exe tests\test_sqlsoup.py
.............................
----------------------------------------------------------------------
Ran 29 tests in 0.549s
OK
What is comes down to is that this method never gets called:
@classmethod
def setup_class(cls):
global engine
engine = create_engine('sqlite://', echo=True)
for sql in _ddl:
engine.execute(sql)
Yes, that's a global variable, I'll improve the unit tests after I get them running.
Pycharm asked me to install nose to satisfy the dependency, so I would assume its test runner is using that module and not a different one. Why is it giving different results?
Upvotes: 0
Views: 158
Reputation: 26
As far as I know for nose, the setup has to be the following format for nose to pickup and run at the start of the test class:
@classmethod
def setUpClass(cls):
global engine
...
Upvotes: 1