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
4c81d60f
Commit
4c81d60f
authored
Jul 23, 2001
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests for the "commands" module, contributed by Nick Mathewson.
This closes SF patch #440291.
parent
15861361
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
0 deletions
+45
-0
Lib/test/test_commands.py
Lib/test/test_commands.py
+45
-0
No files found.
Lib/test/test_commands.py
0 → 100644
View file @
4c81d60f
'''
Tests for commands module
Nick Mathewson
'''
import
unittest
import
os
,
tempfile
,
re
from
test_support
import
TestSkipped
,
run_unittest
from
commands
import
*
# The module says:
# "NB This only works (and is only relevant) for UNIX."
#
# Actually, getoutput should work on any platform with an os.popen, but
# I'll take the comment as given, and skip this suite.
if
os
.
name
!=
'posix'
:
raise
TestSkipped
(
'Not posix; skipping test_commands'
)
class
CommandTests
(
unittest
.
TestCase
):
def
test_getoutput
(
self
):
self
.
assertEquals
(
getoutput
(
'echo xyzzy'
),
'xyzzy'
)
self
.
assertEquals
(
getstatusoutput
(
'echo xyzzy'
),
(
0
,
'xyzzy'
))
# we use mktemp in the next line to get a filename which we
# _know_ won't exist. This is guaranteed to fail.
status
,
output
=
getstatusoutput
(
'cat '
+
tempfile
.
mktemp
())
self
.
assertNotEquals
(
status
,
0
)
def
test_getstatus
(
self
):
# This pattern should match 'ls -ld /bin/ls' on any posix
# system, however perversely configured.
pat
=
r'''-..x..x..x # It is executable.
\
s+
\d+ # It has some number of links.
\
s+
\w+\
s+
\w+ # It has a user and group, which may
# be named anything.
[^/]* # Skip the date.
/bin/ls # and end with the name of the file.
'''
self
.
assert_
(
re
.
match
(
pat
,
getstatus
(
"/bin/ls"
),
re
.
VERBOSE
))
run_unittest
(
CommandTests
)
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