[copr] master: Add a test command to manage.py (5d27203)

bkabrda at fedoraproject.org bkabrda at fedoraproject.org
Tue Feb 19 13:29:46 UTC 2013


Repository : http://git.fedorahosted.org/cgit/copr.git

On branch  : master

>---------------------------------------------------------------

commit 5d27203df35e09ef19f36230321c8460bd74bd20
Author: Bohuslav Kabrda <bkabrda at redhat.com>
Date:   Tue Feb 19 14:28:32 2013 +0100

    Add a test command to manage.py


>---------------------------------------------------------------

 coprs_frontend/manage.py                |   14 ++++++++++++++
 coprs_frontend/tests/coprs_test_case.py |    1 -
 2 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/coprs_frontend/manage.py b/coprs_frontend/manage.py
index 01c5616..f4054fc 100755
--- a/coprs_frontend/manage.py
+++ b/coprs_frontend/manage.py
@@ -1,6 +1,8 @@
 #!/usr/bin/env python
 
+import argparse
 import os
+import subprocess
 
 import flask
 from flask.ext.script import Manager, Command, Option, Group
@@ -11,6 +13,17 @@ from coprs import exceptions
 from coprs import models
 from coprs.logic import coprs_logic
 
+class TestCommand(Command):
+    def run(self, test_args):
+        os.environ['COPRS_ENVIRON_UNITTEST'] = '1'
+        subprocess.call(['py.test'] + test_args)
+
+    option_list = (
+        Option('-a',
+               dest='test_args',
+               nargs=argparse.REMAINDER),
+    )
+
 class CreateSqliteFileCommand(Command):
     'Create the sqlite DB file (not the tables). Used for alembic, "create_db" does this automatically.'
     def run(self):
@@ -162,6 +175,7 @@ class AlterUserCommand(Command):
     )
 
 manager = Manager(app)
+manager.add_command('test', TestCommand())
 manager.add_command('create_sqlite_file', CreateSqliteFileCommand())
 manager.add_command('create_db', CreateDBCommand())
 manager.add_command('drop_db', DropDBCommand())
diff --git a/coprs_frontend/tests/coprs_test_case.py b/coprs_frontend/tests/coprs_test_case.py
index 2028401..82e7a38 100644
--- a/coprs_frontend/tests/coprs_test_case.py
+++ b/coprs_frontend/tests/coprs_test_case.py
@@ -1,6 +1,5 @@
 import base64
 import os
-os.environ['COPRS_ENVIRON_UNITTEST'] = '1'
 
 import pytest
 



More information about the copr-devel mailing list