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
b9286ebd
Commit
b9286ebd
authored
Apr 24, 2006
by
Nick Coghlan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More reliable version of new command line tests that just checks the exit codes
parent
ddd9d572
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
2 deletions
+37
-2
Lib/test/test_cmd_line.py
Lib/test/test_cmd_line.py
+37
-2
No files found.
Lib/test/test_cmd_line.py
View file @
b9286ebd
...
...
@@ -15,8 +15,11 @@ class CmdLineTest(unittest.TestCase):
popen2
.
_cleanup
()
return
data
def
exit_code
(
self
,
cmd_line
):
return
subprocess
.
call
([
sys
.
executable
,
cmd_line
],
stderr
=
subprocess
.
PIPE
)
def
exit_code
(
self
,
*
args
):
cmd_line
=
[
sys
.
executable
]
cmd_line
.
extend
(
args
)
return
subprocess
.
call
(
cmd_line
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
def
test_directories
(
self
):
self
.
assertNotEqual
(
self
.
exit_code
(
'.'
),
0
)
...
...
@@ -50,6 +53,38 @@ class CmdLineTest(unittest.TestCase):
version
=
'Python %d.%d'
%
sys
.
version_info
[:
2
]
self
.
assertTrue
(
self
.
start_python
(
'-V'
).
startswith
(
version
))
def
test_run_module
(
self
):
# Test expected operation of the '-m' switch
# Switch needs an argument
self
.
assertNotEqual
(
self
.
exit_code
(
'-m'
),
0
)
# Check we get an error for a nonexistent module
self
.
assertNotEqual
(
self
.
exit_code
(
'-m'
,
'fnord43520xyz'
),
0
)
# Check the runpy module also gives an error for
# a nonexistent module
self
.
assertNotEqual
(
self
.
exit_code
(
'-m'
,
'runpy'
,
'fnord43520xyz'
),
0
)
# All good if module is located and run successfully
self
.
assertEqual
(
self
.
exit_code
(
'-m'
,
'timeit'
,
'-n'
,
'1'
),
0
)
def
test_run_code
(
self
):
# Test expected operation of the '-c' switch
# Switch needs an argument
self
.
assertNotEqual
(
self
.
exit_code
(
'-c'
),
0
)
# Check we get an error for an uncaught exception
self
.
assertNotEqual
(
self
.
exit_code
(
'-c'
,
'raise Exception'
),
0
)
# All good if execution is successful
self
.
assertEqual
(
self
.
exit_code
(
'-c'
,
'pass'
),
0
)
def
test_main
():
test
.
test_support
.
run_unittest
(
CmdLineTest
)
...
...
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