[PATCH] test_timestamp.py changes for win32

John Arbash Meinel john at arbash-meinel.com
Thu Apr 19 17:20:49 BST 2007


I'm pretty sure Martin's patch supersedes this one. But I wanted to
point out one thing.

...

+
+
+class GmtimeNegativeSecondsFeature(tests.Feature):
+    """Check if underlying platform accepts negative numbers in
time.gmtime"""
+
+    def _probe(self):
+        import time
+        try:
+            time.gmtime(-3600)
+        except ValueError:
+            return False
+        return True
+
+    def feature_name(self):
+        return 'gmtime(-sec)'


I think the proper way of doing features is to turn them into
singletons. By creating:

class _GmtimeNegative...

GmtimeNegativeSecondsFeature = _GmtimeNegative...()

The importance of this is that a given Feature only checks if it is
supported 1 time. Rather than checking every time it is needed.

This is especially important for things that start to get expensive
(like spawning strace to see if it is available).  By using a singleton
we only have to check 1 time regardless if there are 50 tests that need
that feature.

I'd really like to see the test suite updated so that the Transport
tests use features rather than not returning test cases. So you could
see that 500 tests are skipped because of not having paramiko, and 200
are skipped because of not having 'medusa'.

John
=:->



More information about the bazaar mailing list