From: Zooko O'Whielacronx Date: Fri, 10 Sep 2010 15:41:35 +0000 (-0700) Subject: test: make tests stop relying on pyutil version class accepting the string 'unknown... X-Git-Tag: allmydata-tahoe-1.8.0c4~9 X-Git-Url: https://git.rkrishnan.org/pf/content/frontends/$rel_link?a=commitdiff_plain;h=fd17d63c95ee147cfc94ceb36ee2507b7f726d8e;p=tahoe-lafs%2Ftahoe-lafs.git test: make tests stop relying on pyutil version class accepting the string 'unknown' for its version, and make them forward-compatible with the future Python Rational Version Numbering standard --- diff --git a/src/allmydata/test/test_runner.py b/src/allmydata/test/test_runner.py index 8345bb10..75009cb6 100644 --- a/src/allmydata/test/test_runner.py +++ b/src/allmydata/test/test_runner.py @@ -81,14 +81,32 @@ class BinTahoe(common_util.SignalMixin, unittest.TestCase, SkipMixin): out, err, rc_or_sig = res self.failUnlessEqual(rc_or_sig, 0, str(res)) - # Fail unless the package is *this* version *and* was loaded from *this* source directory. - required_ver_and_path = "%s: %s (%s)" % (allmydata.__appname__, allmydata.__version__, srcdir) - self.failUnless(out.startswith(required_ver_and_path), - str((out, err, rc_or_sig, required_ver_and_path))) - - self.failIfEqual(allmydata.__version__, "unknown", - "We don't know our version, because this distribution didn't come " - "with a _version.py and 'setup.py darcsver' hasn't been run.") + # Fail unless the allmydata-tahoe package is *this* version *and* + # was loaded from *this* source directory. + + verstr = str(allmydata.__version__) + + # The Python "rational version numbering" convention + # disallows "-r$REV" but allows ".post$REV" + # instead. Eventually we'll probably move to that. When we + # do, this test won't go red: + + ix = verstr.rfind('-r') + if ix != -1: + altverstr = verstr[:ix] + '.post' + verstr[ix+2:] + else: + ix = verstr.rfind('.post') + if ix != -1: + altverstr = verstr[:ix] + '-r' + verstr[ix+5:] + else: + altverstr = verstr + + ad = os.path.dirname(os.path.dirname(os.path.realpath(allmydata.__file__))) + + required_ver_and_path = "%s: %s (%s)" % (allmydata.__appname__, verstr, ad) + alt_required_ver_and_path = "%s: %s (%s)" % (allmydata.__appname__, altverstr, ad) + + self.failUnless(out.startswith(required_ver_and_path) or out.startswith(alt_required_ver_and_path), (out, err, rc_or_sig, required_ver_and_path)) d.addCallback(_cb) return d diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index 775049bd..7ebafeb8 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -753,8 +753,27 @@ class SystemTest(SystemTestMixin, unittest.TestCase): d = getPage(self.introweb_url, method="GET", followRedirect=True) def _check(res): try: - self.failUnless("%s: %s" % (allmydata.__appname__, allmydata.__version__) - in res) + self.failUnless("%s: %s" % (allmydata.__appname__, allmydata.__version__) in res) + verstr = str(allmydata.__version__) + + # The Python "rational version numbering" convention + # disallows "-r$REV" but allows ".post$REV" + # instead. Eventually we'll probably move to + # that. When we do, this test won't go red: + ix = verstr.rfind('-r') + if ix != -1: + altverstr = verstr[:ix] + '.post' + verstr[ix+2:] + else: + ix = verstr.rfind('.post') + if ix != -1: + altverstr = verstr[:ix] + '-r' + verstr[ix+5:] + else: + altverstr = verstr + + appverstr = "%s: %s" % (allmydata.__appname__, verstr) + newappverstr = "%s: %s" % (allmydata.__appname__, altverstr) + + self.failUnless((appverstr in res) or (newappverstr in res), (appverstr, newappverstr, res)) self.failUnless("Announcement Summary: storage: 5, stub_client: 5" in res) self.failUnless("Subscription Summary: storage: 5" in res) except unittest.FailTest: