Question

I have a Flask app and I am using Flask-Script and Flask-Testing. Basically I have a manage.py file that looks like this:

from flask.ext.script import Manager
from app import app, db

manager = Manager(app)

@manager.command
def test():
    import nose
    nose.main()

if __name__ == '__main__':
    manager.run()

My app tree looks like:

app/
tests/
    __init__.py
    test_one.py
manage.py

__init__.py holds only some things that make Flask-SQLAlchemy things work in tests and test_one.py contains just an empty test function.

The odd things is: When I run python manage.py test, it starts executing some wierd tests (I believe tests from Python itself). If I change nose.main() to nose.main(argv=['']), my test is properly discovered and everything goes well.

What's wrong with using the plain nose.main()?

Was it helpful?

Solution

Nose will read sys.argv if argv is None, i think when you run it like python manage.py test that will get passed to sys.argv.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top