6 from django.core.management.base import BaseCommand, CommandError
7 from django.conf import settings as django_settings
9 from forum import settings
11 class Command(BaseCommand):
12 args = '<test1 test2 test3 ...>'
13 help = 'Closes the specified poll for voting'
15 def handle(self, *args, **options):
16 # Try to load Selenium.
19 print "Selenium has been successfully loaded"
21 logging.error("Couldn't load selenium")
22 exit("Python Selenium couldn't be loaded: pip install selenium")
25 TEST_FOLDER = '%s/forum/skins/%s/tests' % (django_settings.SITE_SRC_ROOT, django_settings.OSQA_DEFAULT_SKIN)
27 # Check if the UI tests folder exists
28 if os.path.exists(TEST_FOLDER):
29 print 'Loading UI tests from %s' % TEST_FOLDER
31 exit("UI tests folder couldn't be loaded")
33 # Loop through all args and try to get the python test files that match
37 matching_files = glob.glob('%s/%s.py' % (TEST_FOLDER, arg))
38 for matching_file in matching_files:
39 files.append(matching_file)
41 # Loop through all test files
43 file_name = file.split('/')[-1]
44 print "Starting test %s" % file_name
45 child = subprocess.Popen('python %s' % file, shell=True)