Эх сурвалжийг харах

Modify how tests are invoked

 The complete test suite is only run in travis
 For local build purposes it is enough to run the tests against SQLite.
Oz Tiram 6 жил өмнө
parent
commit
1f10924ed0

+ 1 - 1
.travis.yml

@@ -31,7 +31,7 @@ install:
   - "pip install ."
 
 script:
-  - python setup.py develop && coverage run -m tests.test_pwman
+  - python setup.py develop && coverage run setup.py integration
 
 after_success:
   - coveralls

+ 21 - 1
setup.py

@@ -73,6 +73,25 @@ class TestCommand(Command):
                              'tests.test_pwman']))
 
 
+class IntegrationTestCommand(Command):
+    user_options = []
+
+    def initialize_options(self):
+        pass
+
+    def finalize_options(self):
+        pass
+
+    def run(self):
+        import sys
+        import subprocess
+
+        raise SystemExit(
+            subprocess.call([sys.executable,
+                             '-m',
+                             'tests.test_integration']))
+
+
 class BuildManPage(Command):
 
     description = 'Generate man page from an ArgumentParser instance.'
@@ -358,7 +377,8 @@ setup(name='pwman3',
                    ],
       cmdclass={
           'build_manpage': BuildManPage,
-          'test': TestCommand
+          'test': TestCommand,
+          'integration': IntegrationTestCommand
       },
       entry_points={
           'console_scripts': ['pwman3 = pwman.ui.cli:main']

+ 21 - 0
tests/test_integration.py

@@ -0,0 +1,21 @@
+import unittest
+
+from .test_postgresql import TestPostGresql
+from .test_mongodb import TestMongoDB
+from .test_mysql import TestMySQLDatabase
+from .test_pwman import suite
+
+
+def complete_suite(suite):
+
+    loader = unittest.TestLoader()
+    suite.addTest(loader.loadTestsFromTestCase(TestPostGresql))
+    suite.addTest(loader.loadTestsFromTestCase(TestMySQLDatabase))
+    suite.addTest(loader.loadTestsFromTestCase(TestMongoDB))
+
+    return suite
+
+
+if __name__ == '__main__':
+    test_suite = complete_suite(suite())
+    unittest.TextTestRunner(verbosity=2, failfast=True).run(test_suite)

+ 4 - 7
tests/test_pwman.py

@@ -24,9 +24,6 @@ import unittest
 from .test_crypto_engine import CryptoEngineTest, TestPassGenerator
 from .test_config import TestConfig
 from .test_sqlite import TestSQLite
-from .test_postgresql import TestPostGresql
-from .test_mysql import TestMySQLDatabase
-from .test_mongodb import TestMongoDB
 from .test_importer import TestImporter
 from .test_factory import TestFactory
 from .test_base_ui import TestBaseUI
@@ -52,9 +49,6 @@ def suite():
     suite.addTest(loader.loadTestsFromTestCase(TestPassGenerator))
     suite.addTest(loader.loadTestsFromTestCase(TestConfig))
     suite.addTest(loader.loadTestsFromTestCase(TestSQLite))
-    suite.addTest(loader.loadTestsFromTestCase(TestPostGresql))
-    suite.addTest(loader.loadTestsFromTestCase(TestMySQLDatabase))
-    suite.addTest(loader.loadTestsFromTestCase(TestMongoDB))
     suite.addTest(loader.loadTestsFromTestCase(TestImporter))
     suite.addTest(loader.loadTestsFromTestCase(TestFactory))
     suite.addTest(loader.loadTestsFromTestCase(TestBaseUI))
@@ -64,5 +58,8 @@ def suite():
         suite.addTest(loader.loadTestsFromTestCase(Ferrum))
     return suite
 
+
 if __name__ == '__main__':
-    unittest.main(verbosity=2, failfast=True)
+    test_suite = suite()
+    unittest.TextTestRunner(verbosity=2,
+                            failfast=True, buffer=False).run(test_suite)