Rev 4879: (jam) Get the test suite running again on Windows, (bug #492561) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Dec 9 02:53:47 GMT 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4879 [merge]
revision-id: pqm at pqm.ubuntu.com-20091209025342-sidvxfcqdgxmuz59
parent: pqm at pqm.ubuntu.com-20091208183223-zh0w93eu1m8n7wj7
parent: john at arbash-meinel.com-20091208214607-c5gbkx533wr3eg84
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2009-12-09 02:53:42 +0000
message:
(jam) Get the test suite running again on Windows, (bug #492561)
modified:
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/test_osutils.py test_osutils.py-20051201224856-e48ee24c12182989
bzrlib/tests/test_selftest.py test_selftest.py-20051202044319-c110a115d8c0456a
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py 2009-12-04 10:16:00 +0000
+++ b/bzrlib/tests/__init__.py 2009-12-08 21:46:07 +0000
@@ -4247,6 +4247,37 @@
UnicodeFilenameFeature = _UnicodeFilenameFeature()
+class ModuleAvailableFeature(Feature):
+ """This is a feature than describes a module we want to be available.
+
+ Declare the name of the module in __init__(), and then after probing, the
+ module will be available as 'self.module'.
+
+ :ivar module: The module if it is available, else None.
+ """
+
+ def __init__(self, module_name):
+ super(ModuleAvailableFeature, self).__init__()
+ self.module_name = module_name
+
+ def _probe(self):
+ try:
+ self._module = __import__(self.module_name, {}, {}, [''])
+ return True
+ except ImportError:
+ return False
+
+ @property
+ def module(self):
+ if self.available(): # Make sure the probe has been done
+ return self._module
+ return None
+
+ def feature_name(self):
+ return self.module_name
+
+
+
def probe_unicode_in_user_encoding():
"""Try to encode several unicode strings to use in unicode-aware tests.
Return first successfull match.
=== modified file 'bzrlib/tests/test_osutils.py'
--- a/bzrlib/tests/test_osutils.py 2009-12-04 10:09:11 +0000
+++ b/bzrlib/tests/test_osutils.py 2009-12-08 21:46:07 +0000
@@ -23,7 +23,6 @@
import socket
import stat
import sys
-import termios
import time
from bzrlib import (
@@ -54,6 +53,8 @@
UTF8DirReaderFeature = _UTF8DirReaderFeature()
+TermIOSFeature = tests.ModuleAvailableFeature('termios')
+
def _already_unicode(s):
return s
@@ -1961,20 +1962,20 @@
sys.stdout = None
self.assertEquals(None, osutils.terminal_width())
- def test_TIOCGWINSZ(self):
+ def test_no_TIOCGWINSZ(self):
+ self.requireFeature(TermIOSFeature)
+ termios = TermIOSFeature.module
# bug 63539 is about a termios without TIOCGWINSZ attribute
- exist = True
try:
orig = termios.TIOCGWINSZ
except AttributeError:
- exist = False
-
- def restore():
- if exist:
+ # We won't remove TIOCGWINSZ, because it doesn't exist anyway :)
+ pass
+ else:
+ def restore():
termios.TIOCGWINSZ = orig
- self.addCleanup(restore)
-
- del termios.TIOCGWINSZ
+ self.addCleanup(restore)
+ del termios.TIOCGWINSZ
del os.environ['BZR_COLUMNS']
del os.environ['COLUMNS']
- self.assertEquals(None, osutils.terminal_width())
+ self.assertIs(None, osutils.terminal_width())
=== modified file 'bzrlib/tests/test_selftest.py'
--- a/bzrlib/tests/test_selftest.py 2009-12-04 09:09:18 +0000
+++ b/bzrlib/tests/test_selftest.py 2009-12-08 21:46:07 +0000
@@ -2497,6 +2497,22 @@
self.assertIs(feature, exception.args[0])
+class TestModuleAvailableFeature(tests.TestCase):
+
+ def test_available_module(self):
+ feature = tests.ModuleAvailableFeature('bzrlib.tests')
+ self.assertEqual('bzrlib.tests', feature.module_name)
+ self.assertEqual('bzrlib.tests', str(feature))
+ self.assertTrue(feature.available())
+ self.assertIs(tests, feature.module)
+
+ def test_unavailable_module(self):
+ feature = tests.ModuleAvailableFeature('bzrlib.no_such_module_exists')
+ self.assertEqual('bzrlib.no_such_module_exists', str(feature))
+ self.assertFalse(feature.available())
+ self.assertIs(None, feature.module)
+
+
class TestSelftestFiltering(tests.TestCase):
def setUp(self):
More information about the bazaar-commits
mailing list