runner.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env python
  2. # testing/runner.py
  3. # Copyright (C) 2005-2017 the SQLAlchemy authors and contributors
  4. # <see AUTHORS file>
  5. #
  6. # This module is part of SQLAlchemy and is released under
  7. # the MIT License: http://www.opensource.org/licenses/mit-license.php
  8. """
  9. Nose test runner module.
  10. This script is a front-end to "nosetests" which
  11. installs SQLAlchemy's testing plugin into the local environment.
  12. The script is intended to be used by third-party dialects and extensions
  13. that run within SQLAlchemy's testing framework. The runner can
  14. be invoked via::
  15. python -m sqlalchemy.testing.runner
  16. The script is then essentially the same as the "nosetests" script, including
  17. all of the usual Nose options. The test environment requires that a
  18. setup.cfg is locally present including various required options.
  19. Note that when using this runner, Nose's "coverage" plugin will not be
  20. able to provide coverage for SQLAlchemy itself, since SQLAlchemy is
  21. imported into sys.modules before coverage is started. The special
  22. script sqla_nose.py is provided as a top-level script which loads the
  23. plugin in a special (somewhat hacky) way so that coverage against
  24. SQLAlchemy itself is possible.
  25. """
  26. from .plugin.noseplugin import NoseSQLAlchemy
  27. import nose
  28. def main():
  29. nose.main(addplugins=[NoseSQLAlchemy()])
  30. def setup_py_test():
  31. """Runner to use for the 'test_suite' entry of your setup.py.
  32. Prevents any name clash shenanigans from the command line
  33. argument "test" that the "setup.py test" command sends
  34. to nose.
  35. """
  36. nose.main(addplugins=[NoseSQLAlchemy()], argv=['runner'])