Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
63a4d818
Commit
63a4d818
authored
Oct 14, 2010
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#9964: fix running test_compileall under -O and -OO.
parent
97b12bc7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
20 deletions
+23
-20
Lib/test/test_compileall.py
Lib/test/test_compileall.py
+23
-20
No files found.
Lib/test/test_compileall.py
View file @
63a4d818
...
@@ -131,22 +131,28 @@ class CommandLineTests(unittest.TestCase):
...
@@ -131,22 +131,28 @@ class CommandLineTests(unittest.TestCase):
assert
sys
.
path
[
0
]
==
self
.
directory
,
'Missing path'
assert
sys
.
path
[
0
]
==
self
.
directory
,
'Missing path'
del
sys
.
path
[
0
]
del
sys
.
path
[
0
]
def
test_pep3147_paths
(
self
):
# Ensure that the default behavior of compileall's CLI is to create
# Ensure that the default behavior of compileall's CLI is to create
# PEP 3147 pyc/pyo files.
# PEP 3147 pyc/pyo files.
for
name
,
ext
,
switch
in
[
retcode
=
subprocess
.
call
(
(
'normal'
,
'pyc'
,
[]),
(
sys
.
executable
,
'-m'
,
'compileall'
,
'-q'
,
self
.
pkgdir
))
(
'optimize'
,
'pyo'
,
[
'-O'
]),
self
.
assertEqual
(
retcode
,
0
)
(
'doubleoptimize'
,
'pyo'
,
[
'-OO'
])
# Verify the __pycache__ directory contents.
]:
cachedir
=
os
.
path
.
join
(
self
.
pkgdir
,
'__pycache__'
)
def
f
(
self
,
ext
=
ext
,
switch
=
switch
):
self
.
assertTrue
(
os
.
path
.
exists
(
cachedir
))
retcode
=
subprocess
.
call
(
ext
=
(
'pyc'
if
__debug__
else
'pyo'
)
[
sys
.
executable
]
+
switch
+
expected
=
sorted
(
base
.
format
(
imp
.
get_tag
(),
ext
)
for
base
in
[
'-m'
,
'compileall'
,
'-q'
,
self
.
pkgdir
])
(
'__init__.{}.{}'
,
'bar.{}.{}'
))
self
.
assertEqual
(
retcode
,
0
)
self
.
assertEqual
(
sorted
(
os
.
listdir
(
cachedir
)),
expected
)
# Verify the __pycache__ directory contents.
# Make sure there are no .pyc files in the source directory.
cachedir
=
os
.
path
.
join
(
self
.
pkgdir
,
'__pycache__'
)
self
.
assertFalse
([
pyc_file
for
pyc_file
in
os
.
listdir
(
self
.
pkgdir
)
self
.
assertTrue
(
os
.
path
.
exists
(
cachedir
))
if
pyc_file
.
endswith
(
ext
)])
expected
=
sorted
(
base
.
format
(
imp
.
get_tag
(),
ext
)
for
base
in
(
'__init__.{}.{}'
,
'bar.{}.{}'
))
self
.
assertEqual
(
sorted
(
os
.
listdir
(
cachedir
)),
expected
)
# Make sure there are no .pyc files in the source directory.
self
.
assertFalse
([
pyc_file
for
pyc_file
in
os
.
listdir
(
self
.
pkgdir
)
if
pyc_file
.
endswith
(
ext
)])
locals
()[
'test_pep3147_paths_'
+
name
]
=
f
def
test_legacy_paths
(
self
):
def
test_legacy_paths
(
self
):
# Ensure that with the proper switch, compileall leaves legacy
# Ensure that with the proper switch, compileall leaves legacy
...
@@ -157,10 +163,7 @@ class CommandLineTests(unittest.TestCase):
...
@@ -157,10 +163,7 @@ class CommandLineTests(unittest.TestCase):
# Verify the __pycache__ directory contents.
# Verify the __pycache__ directory contents.
cachedir
=
os
.
path
.
join
(
self
.
pkgdir
,
'__pycache__'
)
cachedir
=
os
.
path
.
join
(
self
.
pkgdir
,
'__pycache__'
)
self
.
assertFalse
(
os
.
path
.
exists
(
cachedir
))
self
.
assertFalse
(
os
.
path
.
exists
(
cachedir
))
ext
=
(
'pyc'
if
__debug__
else
'pyo'
)
expected
=
sorted
([
'__init__.py'
,
'__init__.pyc'
,
'bar.py'
,
'bar.pyc'
])
expected
=
[
base
.
format
(
ext
)
for
base
in
(
'__init__.{}'
,
'bar.{}'
)]
expected
.
extend
([
'__init__.py'
,
'bar.py'
])
expected
.
sort
()
self
.
assertEqual
(
sorted
(
os
.
listdir
(
self
.
pkgdir
)),
expected
)
self
.
assertEqual
(
sorted
(
os
.
listdir
(
self
.
pkgdir
)),
expected
)
def
test_multiple_runs
(
self
):
def
test_multiple_runs
(
self
):
...
...
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