Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Test" object has no attribute '_ctx' #45

Closed
ghost opened this issue May 5, 2014 · 1 comment
Closed

"Test" object has no attribute '_ctx' #45

ghost opened this issue May 5, 2014 · 1 comment

Comments

@ghost
Copy link

ghost commented May 5, 2014

This is probably related to the change in #24.

Using python 2.7.5 and Flask-Testing==0.4.1

tests.py

#!/usr/bin/env python2.7
import unittest

if __name__ == "__main__":
    suite = unittest.TestLoader().discover('tests')
    unittest.TextTestRunner(verbosity=2).run(suite)

./tests/testApi.py

from flask.ext.testing import TestCase

class TestApi(TestCase):

    def create_app(self):
        app = Flask(__name__)
        app.config['TESTING'] = True
        return app

    def test_server_is_up_and_running(self):
        pass

> ./tests.py

test_helloworld (testHelloWorld.TestHelloWorld) ... ok
Traceback (most recent call last):
  File "./tests.py", line 6, in <module>
    unittest.TextTestRunner(verbosity=2).run(suite)
  File "/usr/lib/python2.7/unittest/runner.py", line 151, in run
    test(result)
  File "/usr/lib/python2.7/unittest/suite.py", line 70, in __call__
    return self.run(*args, **kwds)
  File "/usr/lib/python2.7/unittest/suite.py", line 108, in run
    test(result)
  File "/usr/lib/python2.7/unittest/suite.py", line 70, in __call__
    return self.run(*args, **kwds)
  File "/usr/lib/python2.7/unittest/suite.py", line 108, in run
    test(result)
  File "/usr/lib/python2.7/unittest/suite.py", line 70, in __call__
    return self.run(*args, **kwds)
  File "/usr/lib/python2.7/unittest/suite.py", line 108, in run
    test(result)
  File "/home/bhafichuk/.virtualenvs/kyc/local/lib/python2.7/site-packages/flask_testing/utils.py", line 90, in __call__
    self._post_teardown()
  File "/home/bhafichuk/.virtualenvs/kyc/local/lib/python2.7/site-packages/flask_testing/utils.py", line 116, in _post_teardown
    if self._ctx is not None:
AttributeError: 'TestApi' object has no attribute '_ctx'
@ghost ghost closed this as completed May 5, 2014
@ghost ghost reopened this May 5, 2014
hafichuk added a commit to hafichuk/flask-testing that referenced this issue May 5, 2014
@hafichuk hafichuk mentioned this issue May 5, 2014
@jarus
Copy link
Owner

jarus commented May 19, 2014

You forget to import Flask but there was also a bug inside of the pre_setup and teardown.
Fixed with #48.

@jarus jarus closed this as completed May 19, 2014
@homburg homburg mentioned this issue Jul 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant