← Back to team overview

spv-dev team mailing list archive

[Branch ~spv-dev/slidepresenterview/trunk] Rev 55: [MERGE] lp:~bouf10/slidepresenterview/tests-osspecific

 

Merge authors:
  C. Bolduc (claude-bolduc)
  F.-A. Bourbonnais (bouf10)
Related merge proposals:
  https://code.launchpad.net/~bouf10/slidepresenterview/tests-osspecific/+merge/29663
  proposed by: F.-A. Bourbonnais (bouf10)
  review: Approve - C. Bolduc (claude-bolduc)
  review: Approve - F.-A. Bourbonnais (bouf10)
------------------------------------------------------------
revno: 55 [merge]
committer: Claude Bolduc <claude.bolduc@xxxxxxxxx>
branch nick: trunk
timestamp: Mon 2010-07-12 11:09:24 -0400
message:
  [MERGE] lp:~bouf10/slidepresenterview/tests-osspecific
  Migrate to unittest2 and add support to platform specific testing.
added:
  slidepresenterview/tests/manual/
  slidepresenterview/tests/manual/__init__.py
  slidepresenterview/tests/manual/osspecific.py
modified:
  HACKING
  setup.cfg
  slidepresenterview/tests/__init__.py
  slidepresenterview/tests/unit/docformats/tests_pdf.py
  slidepresenterview/tests/unit/ui/tests_presentation.py
  slidepresenterview/tests/unit/ui/widgets/tests_slideview.py


--
lp:slidepresenterview
https://code.launchpad.net/~spv-dev/slidepresenterview/trunk

Your team SlidePresenterView Development Team is subscribed to branch lp:slidepresenterview.
To unsubscribe from this branch go to https://code.launchpad.net/~spv-dev/slidepresenterview/trunk/+edit-subscription
=== modified file 'HACKING'
--- HACKING	2010-05-05 01:54:25 +0000
+++ HACKING	2010-07-11 17:27:55 +0000
@@ -8,8 +8,8 @@
   - All runtime dependencies
   - PyQt4 dev (for pyuic4)
       * See runtime dependencies
-  - Nose (to run tests)
-      * easy_install nose
+  - Nose >=0.11.2 (to run tests)
+      * easy_install "nose>=0.11.2"
   - Voidspace's Mock
       * Since 2010-01, we use a patched version of Mock. That version
         in already included in thirdparty/mock.py.

=== modified file 'setup.cfg'
--- setup.cfg	2010-05-03 02:55:07 +0000
+++ setup.cfg	2010-07-11 17:27:55 +0000
@@ -5,3 +5,4 @@
 with-freshen=1
 testmatch=(?:^|[\b_\.%s-])([Tt]est|should)
 where=slidepresenterview/
+exclude=slidepresenterview/tests/manual

=== modified file 'slidepresenterview/tests/__init__.py'
--- slidepresenterview/tests/__init__.py	2010-01-07 04:58:32 +0000
+++ slidepresenterview/tests/__init__.py	2010-07-11 23:14:59 +0000
@@ -25,7 +25,7 @@
 
 import os
 import doctest
-import unittest
+import unittest2
 
 
 
@@ -50,6 +50,37 @@
 sys.path.insert(0, os.path.join(BASE_DIR, 'thirdparty'))
 
 
+#########
+# Extensions
+#####
+
+class MultiplePrefixesTestLoader(unittest2.TestLoader):
+    """
+    Extension of TestLoader to support multiple prefixes 
+    for test methods' name
+    
+    By default, prefixes are 'test' and 'should'
+    """
+    
+    testMethodPrefixes = ['test', 'should']
+    
+    def getTestCaseNames(self, testCaseClass):
+        names_all_prefixes = []
+        for prefix in self.testMethodPrefixes:
+            self.testMethodPrefix = prefix
+            names = unittest2.TestLoader.getTestCaseNames(self, testCaseClass)
+            names_all_prefixes.extend(names)
+        return names_all_prefixes
+
+
+def SkipIfNotWindows():
+    return unittest2.skipIf(os.name not in ['win32', 'ce', 'nt'], 
+                            "Not running on Windows (but %s)." % os.name)
+
+def SkipIfNotPosix():
+    return unittest2.skipIf(os.name not in ['posix', 'mac'], 
+                            "Not running on Posix (but %s)." % os.name)
+
 
 ##########
 # Informations

=== added directory 'slidepresenterview/tests/manual'
=== added file 'slidepresenterview/tests/manual/__init__.py'
=== added file 'slidepresenterview/tests/manual/osspecific.py'
--- slidepresenterview/tests/manual/osspecific.py	1970-01-01 00:00:00 +0000
+++ slidepresenterview/tests/manual/osspecific.py	2010-07-11 23:27:26 +0000
@@ -0,0 +1,90 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# 
+# SlidePresenterView - Console for presenters 
+# https://launchpad.net/slidepresenterview
+#
+# Copyright (C) 2010 Felix-Antoine Bourbonnais <bouf10pub _AT@. rubico.info>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+import os
+
+BASE_DIR = '../../..'
+_file_path = os.path.dirname(__file__)
+_base_path = os.path.abspath(os.path.join(_file_path, BASE_DIR))
+
+import sys
+sys.path.insert(0, _base_path)
+
+import unittest2
+import nose
+
+from slidepresenterview.tests import SkipIfNotPosix, SkipIfNotWindows
+
+
+@SkipIfNotWindows()  
+class WindowsTest(unittest2.TestCase):
+    
+    def testUTestsWithWin(self):
+        pass
+
+    def shouldUTestsWithWin(self):
+        pass
+        
+        
+@SkipIfNotPosix()
+class PosixTest(unittest2.TestCase):
+    
+    def testUTestsWithPosix(self):
+        pass
+    
+    def shouldUTestsWithPosix(self):
+        pass
+        
+        
+class PerMethodTest(unittest2.TestCase):
+    
+    @SkipIfNotWindows()
+    def testOnlyWindows(self):
+        pass
+    
+    @SkipIfNotPosix()
+    def testOnlyPosix(self):
+        pass
+    
+    @SkipIfNotWindows()
+    def shouldOnlyWindows(self):
+        pass
+    
+    @SkipIfNotPosix()
+    def shouldOnlyPosix(self):
+        pass
+        
+
+if __name__ == "__main__":
+    from slidepresenterview.tests import MultiplePrefixesTestLoader
+    
+    print "===== Unitest2 ====="
+    unittest2.main(testLoader=MultiplePrefixesTestLoader(), exit=False,
+                   verbosity=2)
+    sys.stdout.flush()
+    sys.stderr.flush()
+    print ""
+    print "===== Nose ====="
+    env = os.environ
+    env['NOSE_TESTMATCH'] = '(?:^|[\b_\.%s-])([Tt]est|should)'
+    env['NOSE_VERBOSE'] = '2'
+    nose.runmodule(env=env)

=== modified file 'slidepresenterview/tests/unit/docformats/tests_pdf.py'
--- slidepresenterview/tests/unit/docformats/tests_pdf.py	2010-02-16 20:25:52 +0000
+++ slidepresenterview/tests/unit/docformats/tests_pdf.py	2010-07-11 17:27:55 +0000
@@ -23,7 +23,7 @@
 Tests for PDF format.
 """
 import os
-import unittest
+import unittest2
 from nose.tools import assert_equals, assert_true
 from mock import Mock, sentinel, patch_new, patch
 
@@ -45,7 +45,7 @@
 
 
 # pylint: disable-msg=W0212,R0904
-class TestContextExistingValidFile5Page(unittest.TestCase):
+class TestContextExistingValidFile5Page(unittest2.TestCase):
     """
     Context for the tests when the file linked to the PDFDocumentQt
     is existing, valid and contains 5 pages.
@@ -95,7 +95,7 @@
 
 
 # pylint: disable-msg=W0212,R0904
-class TestContextExistingFile0Page(unittest.TestCase):
+class TestContextExistingFile0Page(unittest2.TestCase):
     """
     Context for the tests when the file linked to the PDFDocumentQt
     is existing and contains 0 page.
@@ -118,7 +118,7 @@
 
 
 # pylint: disable-msg=W0212,R0904
-class TestContextNonExistingFile(unittest.TestCase):
+class TestContextNonExistingFile(unittest2.TestCase):
     """
     Context for the tests when the file linked to the PDFDocumentQt
     is nonexisting.
@@ -131,7 +131,7 @@
 
 
 # pylint: disable-msg=W0212,R0904
-class TestContextExistingNonPdfFile(unittest.TestCase):
+class TestContextExistingNonPdfFile(unittest2.TestCase):
     """
     Context for the tests when the file linked to the PDFDocumentQt
     is existing but is not a PDF file.
@@ -144,7 +144,7 @@
 
 
 # pylint: disable-msg=W0212,R0904
-class TestContextExistingPdfFile1PageButNoPageRendering(unittest.TestCase):
+class TestContextExistingPdfFile1PageButNoPageRendering(unittest2.TestCase):
     """
     Context for the tests when the file linked to the PDFDocumentQt
     is existing and contains 1 page but the page cannot be rendered.
@@ -177,7 +177,7 @@
 
 
 # pylint: disable-msg=W0212,R0904
-class TestContextPDFDocumentQt1Page(unittest.TestCase):
+class TestContextPDFDocumentQt1Page(unittest2.TestCase):
     """
     Context for the tests when the PDFDocumentQt contains 1 page.
     
@@ -243,7 +243,7 @@
         
 
 # pylint: disable-msg=W0212,R0904
-class TestContextPDFDocumentQt3Pages(unittest.TestCase):
+class TestContextPDFDocumentQt3Pages(unittest2.TestCase):
     """
     Context for the tests when the PDFDocumentQt contains 3 pages.
     
@@ -308,4 +308,5 @@
 
 
 if __name__ == "__main__":
-    unittest.main()
+    from slidepresenterview.tests import MultiplePrefixesTestLoader
+    unittest2.main(testLoader=MultiplePrefixesTestLoader())

=== modified file 'slidepresenterview/tests/unit/ui/tests_presentation.py'
--- slidepresenterview/tests/unit/ui/tests_presentation.py	2010-01-28 17:06:19 +0000
+++ slidepresenterview/tests/unit/ui/tests_presentation.py	2010-07-11 17:27:55 +0000
@@ -22,7 +22,7 @@
 """
 Unit tests for L{slidepresenterview.ui.presentation}.
 """
-import unittest
+import unittest2
 
 from mock import Mock, sentinel, patch_new, patch
 
@@ -64,7 +64,7 @@
 #####
 
 # pylint: disable-msg=W0212,R0904
-class TestContextEmptyPresentationWithoutColleague(unittest.TestCase):
+class TestContextEmptyPresentationWithoutColleague(unittest2.TestCase):
     """
     Tests for an empty L{Presentation} without colleague.
     """
@@ -130,7 +130,7 @@
 
 
 # pylint: disable-msg=W0212,R0904
-class TestAbstractContextEmptyPresentationWithTwoColleagues(unittest.TestCase):
+class TestAbstractContextEmptyPresentationWithTwoColleagues(unittest2.TestCase):
     """
     Abstract context for tests of an empty L{Presentation} with two colleagues.
     """
@@ -602,7 +602,7 @@
 
 
 # pylint: disable-msg=W0212,R0904
-class TestContext3pPresentationAtP2WithoutColleague(unittest.TestCase):
+class TestContext3pPresentationAtP2WithoutColleague(unittest2.TestCase):
     """
     Tests for a L{Presentation} having 3 pages and currently being at page 2 
     without colleague.
@@ -657,4 +657,5 @@
 
 
 if __name__ == "__main__":
-    unittest.main()
+    from slidepresenterview.tests import MultiplePrefixesTestLoader
+    unittest2.main(testLoader=MultiplePrefixesTestLoader())

=== modified file 'slidepresenterview/tests/unit/ui/widgets/tests_slideview.py'
--- slidepresenterview/tests/unit/ui/widgets/tests_slideview.py	2010-02-01 04:12:47 +0000
+++ slidepresenterview/tests/unit/ui/widgets/tests_slideview.py	2010-07-11 17:27:55 +0000
@@ -22,7 +22,7 @@
 """
 Unit tests for L{slidepresenterview.ui.widgets.slideview}.
 """
-import unittest
+import unittest2
 
 from mock import Mock, patch_new
 
@@ -47,7 +47,7 @@
 
 # pylint: disable-msg=W0212,R0904
 class TestContextEmptySlideViewStretchableWithoutPresentation(
-                                                            unittest.TestCase):
+                                                            unittest2.TestCase):
     """
     Tests for an empty L{SlideViewStretchable} that does not know a 
     presentation.
@@ -104,7 +104,7 @@
 
 # pylint: disable-msg=W0212,R0904
 class TestAbstractContextEmptySlideViewStretchableWithPresentation(
-                                                            unittest.TestCase):
+                                                            unittest2.TestCase):
     """
     Abstract context for tests of a L{SlideViewStretchable} that knows a 
     presentation.
@@ -583,4 +583,5 @@
 
 
 if __name__ == "__main__":
-    unittest.main()
+    from slidepresenterview.tests import MultiplePrefixesTestLoader
+    unittest2.main(testLoader=MultiplePrefixesTestLoader())