문제

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()?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top