PageRenderTime 60ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/sikuli-script/src/test/python/RunNoseTests.py

https://bitbucket.org/jaharmi/sikuli
Python | 42 lines | 37 code | 2 blank | 3 comment | 1 complexity | 330da857e4149672cd13d3941cb20ae5 MD5 | raw file
  1. # Copyright 2010-2011, Sikuli.org
  2. # Released under the MIT License.
  3. # Setup the environment
  4. import os, sys, site, urllib2, tempfile
  5. TESTS_DIR = sys.path[0]
  6. cwd = os.getcwdu()
  7. site_dir = os.path.join(os.getcwdu(), 'site-packages')
  8. if not os.path.exists(site_dir): os.mkdir(site_dir)
  9. site.addsitedir(site_dir)
  10. sys.executable = ''
  11. os.environ['PYTHONPATH'] = os.pathsep.join(sys.path)
  12. # Get ez_setup:
  13. ez_setup_path = os.path.join(site_dir, 'ez_setup.py')
  14. if not os.path.exists(ez_setup_path):
  15. f = file(ez_setup_path, 'w')
  16. f.write(urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py').read())
  17. f.close()
  18. # Install nose if not present
  19. try:
  20. import nose
  21. except ImportError:
  22. import ez_setup
  23. ez_setup.main(['--install-dir', site_dir, 'nose'])
  24. for mod in sys.modules.keys():
  25. if mod.startswith('nose'):
  26. del sys.modules[mod]
  27. for path in sys.path:
  28. if path.startswith(site_dir):
  29. sys.path.remove(site_dir)
  30. site.addsitedir(site_dir)
  31. import nose
  32. print "find tests in ", TESTS_DIR
  33. # Run Tests!
  34. nose.run(argv=['nosetests', '-v', '--with-xunit', '--where='+TESTS_DIR, '--xunit-file='+cwd+'/TEST-Sikuli-Python-Suite.xml'] + sys.argv[1:])