1

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

linkyndy
  • 17,038
  • 20
  • 114
  • 194
  • Can you show some output of the `nose.main()` command (which tests are getting run) ? Thing is 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 to `sys.argv`, not sure though, your output will help. – jbub Nov 29 '13 at 16:38
  • Yes, this was the problem. `nose.main()` was passed `sys.argv` and it was searching for some weird tests. You can submit your answer :) – linkyndy Nov 29 '13 at 21:59

1 Answers1

2

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.

jbub
  • 2,586
  • 23
  • 23