[pypy-svn] r58766 - in pypy/branch/2.5-merge/pypy/module/sys: . test

arigo at codespeak.net arigo at codespeak.net
Tue Oct 7 16:56:46 CEST 2008


Author: arigo
Date: Tue Oct  7 16:56:46 2008
New Revision: 58766

Modified:
   pypy/branch/2.5-merge/pypy/module/sys/__init__.py
   pypy/branch/2.5-merge/pypy/module/sys/test/test_sysmodule.py
   pypy/branch/2.5-merge/pypy/module/sys/version.py
Log:
Implement sys.subversion.


Modified: pypy/branch/2.5-merge/pypy/module/sys/__init__.py
==============================================================================
--- pypy/branch/2.5-merge/pypy/module/sys/__init__.py	(original)
+++ pypy/branch/2.5-merge/pypy/module/sys/__init__.py	Tue Oct  7 16:56:46 2008
@@ -55,6 +55,7 @@
         'version'               : 'version.get_version(space)',
         'pypy_version_info'     : 'version.get_pypy_version_info(space)',
         'pypy_svn_url'          : 'version.get_svn_url(space)',
+        'subversion'            : 'version.get_subversion_info(space)',
         'hexversion'            : 'version.get_hexversion(space)',
         'ps1'                   : 'space.wrap(">>>> ")', 
         'ps2'                   : 'space.wrap(".... ")', 
@@ -64,7 +65,6 @@
         'meta_path'             : 'space.wrap([])',
         'path_hooks'            : 'space.wrap([])',
         'path_importer_cache'   : 'space.wrap({})',
-        #'subversion'           : added in Python 2.5
         
         'getdefaultencoding'    : 'interp_encoding.getdefaultencoding', 
         'setdefaultencoding'    : 'interp_encoding.setdefaultencoding',

Modified: pypy/branch/2.5-merge/pypy/module/sys/test/test_sysmodule.py
==============================================================================
--- pypy/branch/2.5-merge/pypy/module/sys/test/test_sysmodule.py	(original)
+++ pypy/branch/2.5-merge/pypy/module/sys/test/test_sysmodule.py	Tue Oct  7 16:56:46 2008
@@ -377,3 +377,9 @@
 
     def test_allattributes(self):
         sys.__dict__   # check that we don't crash initializing any attribute
+
+    def test_subversion(self):
+        project, svnbranch, revision = sys.subversion
+        assert project == 'PyPy'
+        assert svnbranch == svnbranch.strip('/')
+        assert revision.isdigit()

Modified: pypy/branch/2.5-merge/pypy/module/sys/version.py
==============================================================================
--- pypy/branch/2.5-merge/pypy/module/sys/version.py	(original)
+++ pypy/branch/2.5-merge/pypy/module/sys/version.py	Tue Oct  7 16:56:46 2008
@@ -10,6 +10,7 @@
 PYPY_VERSION               = (1, 0, 0, "alpha", '?')
 # the last item is replaced by the svn revision ^^^
 
+SVN_URL_HEAD = 'http://codespeak.net/svn/pypy/'
 SVN_URL = "$HeadURL$"[10:-28]
 
 REV = "$LastChangedRevision$"[22:-2]
@@ -48,6 +49,13 @@
 def get_svn_url(space):
     return space.wrap((SVN_URL, svn_revision()))
 
+def get_subversion_info(space):
+    assert SVN_URL.startswith(SVN_URL_HEAD)
+    svnbranch = SVN_URL[len(SVN_URL_HEAD):].strip('/')
+    return space.newtuple([space.wrap('PyPy'),
+                           space.wrap(svnbranch),
+                           space.wrap(str(svn_revision()))])
+
 def tuple2hex(ver):
     d = {'alpha':     0xA,
          'beta':      0xB,



More information about the Pypy-commit mailing list