[Zope-Checkins] SVN: Zope/branches/2.10/lib/python/App/ Merged trunk r94458 and r94532 into 2.10 branch.
Log message for revision 94534: Merged trunk r94458 and r94532 into 2.10 branch. Replace messy tests with cleaned-up versions from trunk. Changed: U Zope/branches/2.10/lib/python/App/tests/test_version_txt.py U Zope/branches/2.10/lib/python/App/version_txt.py -=- Modified: Zope/branches/2.10/lib/python/App/tests/test_version_txt.py === --- Zope/branches/2.10/lib/python/App/tests/test_version_txt.py 2009-01-05 12:03:11 UTC (rev 94533) +++ Zope/branches/2.10/lib/python/App/tests/test_version_txt.py 2009-01-05 12:09:46 UTC (rev 94534) @@ -15,41 +15,51 @@ $Id$ -import os import unittest -import Zope2 -import App.version_txt class VersionTextTestCase(unittest.TestCase): def setUp(self): -self.fn = os.path.join(os.path.dirname(Zope2.__file__), version.txt) -App.version_txt._test_reset() +self._resetModuleGlobals() def tearDown(self): -try: -os.unlink(self.fn) -except OSError: -pass +import os +from App.version_txt import _version_file +if _version_file is not None: +os.unlink(_version_file) +self._resetModuleGlobals() +def _resetModuleGlobals(self): +from App import version_txt +version_txt._filename = 'version.txt' +version_txt._version_file = None +version_txt._version_string = None +version_txt._zope_version = None + def writeVersion(self, s): -f = open(self.fn, 'w') -f.write(s) -f.close() +import os +import tempfile +from App import version_txt +assert version_txt._version_file is None +f, version_txt._version_file = tempfile.mkstemp() +os.write(f, s) +os.close(f) def test_without_version_txt(self): -self.assertEqual(App.version_txt.getZopeVersion(), - (-1, -1, -1, '', -1)) +from App import version_txt +from App.version_txt import getZopeVersion +version_txt._filename = '' +self.assertEqual(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.assertEqual(App.version_txt.getZopeVersion(), - (2, 6, 1, '', -1)) +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.assertEqual(App.version_txt.getZopeVersion(), - (2, 6, 1, 'b', 2)) +self.assertEqual(getZopeVersion(), (2, 6, 1, 'b', 2)) def test_suite(): Modified: Zope/branches/2.10/lib/python/App/version_txt.py === --- Zope/branches/2.10/lib/python/App/version_txt.py2009-01-05 12:03:11 UTC (rev 94533) +++ Zope/branches/2.10/lib/python/App/version_txt.py2009-01-05 12:09:46 UTC (rev 94534) @@ -14,24 +14,29 @@ $id$ -import os, sys, re +import os +import re +import sys import Zope2 +_location = os.path.dirname(Zope2.__file__) +_filename = 'version.txt' + +_version_file = None _version_string = None _zope_version = None -def _test_reset(): -# Needed for testing. -global _version_string, _zope_version -_version_string = None -_zope_version = None +def _get_filename(): +if _version_file is not None: +return _version_file +return os.path.join(_location, _filename) def _prep_version_data(): global _version_string, _zope_version if _version_string is None: v = sys.version_info pyver = python %d.%d.%d, %s % (v[0], v[1], v[2], sys.platform) -fn = os.path.join(os.path.dirname(Zope2.__file__), 'version.txt') +fn = _get_filename() expr = re.compile( r'(?Pproduct[A-Za-z0-9]+) +(?Pmajor[0-9]+)' '\.(?Pminor[0-9]+)\.(?Pmicro[0-9]+)' ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/lib/python/App/ Make the 'Cannot open version.txt' case testable.
Log message for revision 94532: Make the 'Cannot open version.txt' case testable. Changed: U Zope/trunk/lib/python/App/tests/test_version_txt.py U Zope/trunk/lib/python/App/version_txt.py -=- Modified: Zope/trunk/lib/python/App/tests/test_version_txt.py === --- Zope/trunk/lib/python/App/tests/test_version_txt.py 2009-01-05 10:57:16 UTC (rev 94531) +++ Zope/trunk/lib/python/App/tests/test_version_txt.py 2009-01-05 11:36:02 UTC (rev 94532) @@ -31,6 +31,7 @@ def _resetModuleGlobals(self): from App import version_txt +version_txt._filename = 'version.txt' version_txt._version_file = None version_txt._version_string = None version_txt._zope_version = None @@ -45,7 +46,9 @@ os.close(f) def test_without_version_txt(self): +from App import version_txt from App.version_txt import getZopeVersion +version_txt._filename = '' self.assertEqual(getZopeVersion(), (-1, -1, -1, '', -1)) def test_with_version_txt_final(self): Modified: Zope/trunk/lib/python/App/version_txt.py === --- Zope/trunk/lib/python/App/version_txt.py2009-01-05 10:57:16 UTC (rev 94531) +++ Zope/trunk/lib/python/App/version_txt.py2009-01-05 11:36:02 UTC (rev 94532) @@ -17,16 +17,19 @@ import os import re import sys +import Zope2 +_location = os.path.dirname(Zope2.__file__) +_filename = 'version.txt' + _version_file = None _version_string = None _zope_version = None def _get_filename(): -import Zope2 if _version_file is not None: return _version_file -return os.path.join(os.path.dirname(Zope2.__file__), 'version.txt') +return os.path.join(_location, _filename) def _prep_version_data(): global _version_string, _zope_version ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.11/lib/python/App/ Backport version_txt import tidying from trunk.
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.py2009-01-05 16:50:53 UTC (rev 94538) +++ Zope/branches/2.11/lib/python/App/version_txt.py2009-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(): ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.11/lib/python/App/ Merged trunk r94458 and r94532 into 2.11 branch.
Log message for revision 94533: Merged trunk r94458 and r94532 into 2.11 branch. Replace messy tests with cleaned-up versions from trunk. The old tests deleted 'Zope2/version.txt' - WTFBBQ? 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 11:36:02 UTC (rev 94532) +++ Zope/branches/2.11/lib/python/App/tests/test_version_txt.py 2009-01-05 12:03:11 UTC (rev 94533) @@ -15,41 +15,51 @@ $Id$ -import os import unittest -import Zope2 -import App.version_txt class VersionTextTestCase(unittest.TestCase): def setUp(self): -self.fn = os.path.join(os.path.dirname(Zope2.__file__), version.txt) -App.version_txt._test_reset() +self._resetModuleGlobals() def tearDown(self): -try: -os.unlink(self.fn) -except OSError: -pass +import os +from App.version_txt import _version_file +if _version_file is not None: +os.unlink(_version_file) +self._resetModuleGlobals() +def _resetModuleGlobals(self): +from App import version_txt +version_txt._filename = 'version.txt' +version_txt._version_file = None +version_txt._version_string = None +version_txt._zope_version = None + def writeVersion(self, s): -f = open(self.fn, 'w') -f.write(s) -f.close() +import os +import tempfile +from App import version_txt +assert version_txt._version_file is None +f, version_txt._version_file = tempfile.mkstemp() +os.write(f, s) +os.close(f) def test_without_version_txt(self): -self.assertEqual(App.version_txt.getZopeVersion(), - (-1, -1, -1, '', -1)) +from App import version_txt +from App.version_txt import getZopeVersion +version_txt._filename = '' +self.assertEqual(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.assertEqual(App.version_txt.getZopeVersion(), - (2, 6, 1, '', -1)) +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.assertEqual(App.version_txt.getZopeVersion(), - (2, 6, 1, 'b', 2)) +self.assertEqual(getZopeVersion(), (2, 6, 1, 'b', 2)) def test_suite(): Modified: Zope/branches/2.11/lib/python/App/version_txt.py === --- Zope/branches/2.11/lib/python/App/version_txt.py2009-01-05 11:36:02 UTC (rev 94532) +++ Zope/branches/2.11/lib/python/App/version_txt.py2009-01-05 12:03:11 UTC (rev 94533) @@ -14,24 +14,29 @@ $id$ -import os, sys, re +import os +import re +import sys import Zope2 +_location = os.path.dirname(Zope2.__file__) +_filename = 'version.txt' + +_version_file = None _version_string = None _zope_version = None -def _test_reset(): -# Needed for testing. -global _version_string, _zope_version -_version_string = None -_zope_version = None +def _get_filename(): +if _version_file is not None: +return _version_file +return os.path.join(_location, _filename) def _prep_version_data(): global _version_string, _zope_version if _version_string is None: v = sys.version_info pyver = python %d.%d.%d, %s % (v[0], v[1], v[2], sys.platform) -fn = os.path.join(os.path.dirname(Zope2.__file__), 'version.txt') +fn = _get_filename() expr = re.compile( r'(?Pproduct[A-Za-z0-9]+) +(?Pmajor[0-9]+)' '\.(?Pminor[0-9]+)\.(?Pmicro[0-9]+)' ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.10/lib/python/App/ Backport version_txt import tidying from trunk.
Log message for revision 94538: Backport version_txt import tidying from trunk. Changed: U Zope/branches/2.10/lib/python/App/tests/test_version_txt.py U Zope/branches/2.10/lib/python/App/version_txt.py -=- Modified: Zope/branches/2.10/lib/python/App/tests/test_version_txt.py === --- Zope/branches/2.10/lib/python/App/tests/test_version_txt.py 2009-01-05 16:40:13 UTC (rev 94537) +++ Zope/branches/2.10/lib/python/App/tests/test_version_txt.py 2009-01-05 16:50:53 UTC (rev 94538) @@ -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.10/lib/python/App/version_txt.py === --- Zope/branches/2.10/lib/python/App/version_txt.py2009-01-05 16:40:13 UTC (rev 94537) +++ Zope/branches/2.10/lib/python/App/version_txt.py2009-01-05 16:50:53 UTC (rev 94538) @@ -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(): ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/lib/python/App/ App.version_txt: avoid possible import cycle by deferring import of Zope2.
Log message for revision 94537: App.version_txt: avoid possible import cycle by deferring import of Zope2. o Also, weak without_version_txt test to use non-existing filename, rather than the (existing) Zope2 directory. Changed: U Zope/trunk/lib/python/App/tests/test_version_txt.py U Zope/trunk/lib/python/App/version_txt.py -=- Modified: Zope/trunk/lib/python/App/tests/test_version_txt.py === --- Zope/trunk/lib/python/App/tests/test_version_txt.py 2009-01-05 14:52:15 UTC (rev 94536) +++ Zope/trunk/lib/python/App/tests/test_version_txt.py 2009-01-05 16:40:13 UTC (rev 94537) @@ -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/trunk/lib/python/App/version_txt.py === --- Zope/trunk/lib/python/App/version_txt.py2009-01-05 14:52:15 UTC (rev 94536) +++ Zope/trunk/lib/python/App/version_txt.py2009-01-05 16:40:13 UTC (rev 94537) @@ -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(): ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins