[Zope-Checkins] SVN: Zope/branches/2.11/lib/python/App/ Backport version_txt import tidying from trunk.
Tres Seaver
tseaver at palladion.com
Mon Jan 5 11:53:07 EST 2009
Log message for revision 94539:
Backport version_txt import tidying from trunk.
Changed:
U Zope/branches/2.11/lib/python/App/tests/test_version_txt.py
U Zope/branches/2.11/lib/python/App/version_txt.py
-=-
Modified: Zope/branches/2.11/lib/python/App/tests/test_version_txt.py
===================================================================
--- Zope/branches/2.11/lib/python/App/tests/test_version_txt.py 2009-01-05 16:50:53 UTC (rev 94538)
+++ Zope/branches/2.11/lib/python/App/tests/test_version_txt.py 2009-01-05 16:53:07 UTC (rev 94539)
@@ -36,7 +36,7 @@
version_txt._version_string = None
version_txt._zope_version = None
- def writeVersion(self, s):
+ def _writeVersion(self, s):
import os
import tempfile
from App import version_txt
@@ -46,19 +46,20 @@
os.close(f)
def test_without_version_txt(self):
+ import os
from App import version_txt
- from App.version_txt import getZopeVersion
- version_txt._filename = ''
- self.assertEqual(getZopeVersion(), (-1, -1, -1, '', -1))
+ version_txt._filename = 'NONESUCHFILESHOULDEXIST'
+ self.failIf(os.path.exists(version_txt._get_filename()))
+ self.assertEqual(version_txt.getZopeVersion(), (-1, -1, -1, '', -1))
def test_with_version_txt_final(self):
from App.version_txt import getZopeVersion
- self.writeVersion("Zope 2.6.1 (source release, python 2.1, linux2)")
+ self._writeVersion("Zope 2.6.1 (source release, python 2.1, linux2)")
self.assertEqual(getZopeVersion(), (2, 6, 1, '', -1))
def test_with_version_txt_beta(self):
from App.version_txt import getZopeVersion
- self.writeVersion("Zope 2.6.1b2 (source release, python 2.1, linux2)")
+ self._writeVersion("Zope 2.6.1b2 (source release, python 2.1, linux2)")
self.assertEqual(getZopeVersion(), (2, 6, 1, 'b', 2))
Modified: Zope/branches/2.11/lib/python/App/version_txt.py
===================================================================
--- Zope/branches/2.11/lib/python/App/version_txt.py 2009-01-05 16:50:53 UTC (rev 94538)
+++ Zope/branches/2.11/lib/python/App/version_txt.py 2009-01-05 16:53:07 UTC (rev 94539)
@@ -17,9 +17,8 @@
import os
import re
import sys
-import Zope2
-_location = os.path.dirname(Zope2.__file__)
+_location = None
_filename = 'version.txt'
_version_file = None
@@ -27,8 +26,12 @@
_zope_version = None
def _get_filename():
+ global _location
if _version_file is not None:
return _version_file
+ if _location is None:
+ import Zope2
+ _location = os.path.dirname(Zope2.__file__)
return os.path.join(_location, _filename)
def _prep_version_data():
More information about the Zope-Checkins
mailing list