Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
a725190a
Commit
a725190a
authored
Aug 08, 2009
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merged c102575 from the 2.12 branch
parent
bc07ba15
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
102 deletions
+15
-102
src/App/tests/test_version_txt.py
src/App/tests/test_version_txt.py
+0
-70
src/App/version_txt.py
src/App/version_txt.py
+15
-32
No files found.
src/App/tests/test_version_txt.py
deleted
100644 → 0
View file @
bc07ba15
##############################################################################
#
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Tests of the version number extraction.
$Id$
"""
import
unittest
class
VersionTextTestCase
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
_resetModuleGlobals
()
def
tearDown
(
self
):
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
):
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
):
import
os
from
App
import
version_txt
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
.
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
(
getZopeVersion
(),
(
2
,
6
,
1
,
'b'
,
2
))
def
test_suite
():
return
unittest
.
makeSuite
(
VersionTextTestCase
)
if
__name__
==
"__main__"
:
unittest
.
main
(
defaultTest
=
"test_suite"
)
src/App/version_txt.py
View file @
a725190a
...
@@ -14,44 +14,26 @@
...
@@ -14,44 +14,26 @@
$id$
$id$
"""
"""
import
os
import
re
import
re
import
sys
import
sys
_location
=
None
import
pkg_resources
_filename
=
'version.txt'
_version_file
=
None
_version_string
=
None
_version_string
=
None
_zope_version
=
None
_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
():
def
_prep_version_data
():
global
_version_string
,
_zope_version
global
_version_string
,
_zope_version
if
_version_string
is
None
:
if
_version_string
is
None
:
v
=
sys
.
version_info
v
=
sys
.
version_info
pyver
=
"python %d.%d.%d, %s"
%
(
v
[
0
],
v
[
1
],
v
[
2
],
sys
.
platform
)
pyver
=
"python %d.%d.%d, %s"
%
(
v
[
0
],
v
[
1
],
v
[
2
],
sys
.
platform
)
fn
=
_get_filename
()
dist
=
pkg_resources
.
get_distribution
(
'Zope2'
)
expr
=
re
.
compile
(
expr
=
re
.
compile
(
r'(?P<product>[A-Za-z0-9]+) +(?P<major>[0-9]+)'
r'(?P<major>[0-9]+)\
.(?P<mi
nor>[0-9]+)\
.(?P<mic
ro>[0-9]+)'
'
\
.(?P<mi
n
or>[0-9]+)
\
.(?P<mic
r
o>[0-9]+)'
'(?P<status>[A-Za-z]+)?(?P<release>[0-9]+)?'
)
'(?P<status>[A-Za-z]+)?(?P<release>[0-9]+)?'
)
try
:
s
=
open
(
fn
).
read
().
strip
()
dict
=
expr
.
match
(
dist
.
version
).
groupdict
()
except
IOError
:
ss
=
'unreleased version'
_zope_version
=
(
-
1
,
-
1
,
-
1
,
''
,
-
1
)
else
:
ss
=
re
.
sub
(
"
\
(.*?
\
)
\
?
"
,"",s)
dict = expr.match(s).groupdict()
_zope_version
=
(
_zope_version
=
(
int
(
dict
.
get
(
'major'
)
or
-
1
),
int
(
dict
.
get
(
'major'
)
or
-
1
),
int
(
dict
.
get
(
'minor'
)
or
-
1
),
int
(
dict
.
get
(
'minor'
)
or
-
1
),
...
@@ -59,13 +41,14 @@ def _prep_version_data():
...
@@ -59,13 +41,14 @@ def _prep_version_data():
dict
.
get
(
'status'
)
or
''
,
dict
.
get
(
'status'
)
or
''
,
int
(
dict
.
get
(
'release'
)
or
-
1
),
int
(
dict
.
get
(
'release'
)
or
-
1
),
)
)
_version_string = "
%
s
,
%
s
" % (
ss
, pyver)
_version_string
=
"%s, %s"
%
(
dist
.
version
,
pyver
)
def
version_txt
():
def
version_txt
():
_prep_version_data
()
_prep_version_data
()
return
'(%s)'
%
_version_string
return
'(%s)'
%
_version_string
def
getZopeVersion
():
def
getZopeVersion
():
"""
"""
Format of zope_version tuple:
Format of zope_version tuple:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment