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
83feff56
Commit
83feff56
authored
Aug 23, 2011
by
Ezio Melotti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#6484: refactor a bit the tests.
parent
91f948a7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
52 deletions
+70
-52
Lib/test/test_mailcap.py
Lib/test/test_mailcap.py
+70
-52
No files found.
Lib/test/test_mailcap.py
View file @
83feff56
...
@@ -9,35 +9,47 @@ MAILCAPFILE = test.support.findfile("mailcap.txt")
...
@@ -9,35 +9,47 @@ MAILCAPFILE = test.support.findfile("mailcap.txt")
# Dict to act as mock mailcap entry for this test
# Dict to act as mock mailcap entry for this test
# The keys and values should match the contents of MAILCAPFILE
# The keys and values should match the contents of MAILCAPFILE
MAILCAPDICT
=
{
'application/x-movie'
:
[{
'compose'
:
'moviemaker %s'
,
MAILCAPDICT
=
{
'application/x-movie'
:
[{
'compose'
:
'moviemaker %s'
,
'x11-bitmap'
:
'"/usr/lib/Zmail/bitmaps/movie.xbm"'
,
'x11-bitmap'
:
'"/usr/lib/Zmail/bitmaps/movie.xbm"'
,
'description'
:
'"Movie"'
,
'description'
:
'"Movie"'
,
'view'
:
'movieplayer %s'
}],
'view'
:
'movieplayer %s'
}],
'application/*'
:
[{
'copiousoutput'
:
''
,
'application/*'
:
[{
'copiousoutput'
:
''
,
'view'
:
'echo "This is
\
\
"%t
\
\
" but is 50
\
\
% Greek to me"
\
\
; cat %s'
}],
'view'
:
'echo "This is
\
\
"%t
\
\
" but is 50
\
\
% Greek to me"
\
\
; cat %s'
}],
'audio/basic'
:
[{
'edit'
:
'audiocompose %s'
,
'audio/basic'
:
[{
'edit'
:
'audiocompose %s'
,
'compose'
:
'audiocompose %s'
,
'compose'
:
'audiocompose %s'
,
'description'
:
'"An audio fragment"'
,
'description'
:
'"An audio fragment"'
,
'view'
:
'showaudio %s'
}],
'view'
:
'showaudio %s'
}],
'video/mpeg'
:
[{
'view'
:
'mpeg_play %s'
}],
'video/mpeg'
:
'application/postscript'
:
[{
'needsterminal'
:
''
,
[{
'view'
:
'mpeg_play %s'
}],
'view'
:
'ps-to-terminal %s'
},
'application/postscript'
:
{
'compose'
:
'idraw %s'
,
[{
'needsterminal'
:
''
,
'view'
:
'ps-to-terminal %s'
},
'view'
:
'ps-to-terminal %s'
}],
{
'compose'
:
'idraw %s'
,
'view'
:
'ps-to-terminal %s'
}],
'application/x-dvi'
:
[{
'view'
:
'xdvi %s'
}],
'application/x-dvi'
:
'message/external-body'
:
[{
'composetyped'
:
'extcompose %s'
,
[{
'view'
:
'xdvi %s'
}],
'message/external-body'
:
[{
'composetyped'
:
'extcompose %s'
,
'description'
:
'"A reference to data stored in an external location"'
,
'description'
:
'"A reference to data stored in an external location"'
,
'needsterminal'
:
''
,
'needsterminal'
:
''
,
'view'
:
'showexternal %s %{access-type} %{name} %{site} %{directory} %{mode} %{server}'
}],
'view'
:
'showexternal %s %{access-type} %{name} %{site} %{directory} %{mode} %{server}'
}],
'text/richtext'
:
[{
'test'
:
'test "`echo %{charset} | tr
\
'
[A-Z]
\
'
\
'
[a-z]
\
'
`" = iso-8859-8'
,
'text/richtext'
:
[{
'test'
:
'test "`echo %{charset} | tr
\
'
[A-Z]
\
'
\
'
[a-z]
\
'
`" = iso-8859-8'
,
'copiousoutput'
:
''
,
'copiousoutput'
:
''
,
'view'
:
'shownonascii iso-8859-8 -e richtext -p %s'
}],
'view'
:
'shownonascii iso-8859-8 -e richtext -p %s'
}],
'image/x-xwindowdump'
:
[{
'view'
:
'display %s'
}],
'image/x-xwindowdump'
:
'audio/*'
:
[{
'view'
:
'/usr/local/bin/showaudio %t'
}],
[{
'view'
:
'display %s'
}],
'video/*'
:
[{
'view'
:
'animate %s'
}],
'audio/*'
:
'application/frame'
:
[{
'print'
:
'"cat %s | lp"'
,
[{
'view'
:
'/usr/local/bin/showaudio %t'
}],
'view'
:
'showframe %s'
}],
'video/*'
:
'image/rgb'
:
[{
'view'
:
'display %s'
}]}
[{
'view'
:
'animate %s'
}],
'application/frame'
:
[{
'print'
:
'"cat %s | lp"'
,
'view'
:
'showframe %s'
}],
'image/rgb'
:
[{
'view'
:
'display %s'
}]
}
class
HelperFunctionTest
(
unittest
.
TestCase
):
class
HelperFunctionTest
(
unittest
.
TestCase
):
...
@@ -47,8 +59,9 @@ class HelperFunctionTest(unittest.TestCase):
...
@@ -47,8 +59,9 @@ class HelperFunctionTest(unittest.TestCase):
# So verify that listmailcapfiles() returns a list of strings that is of
# So verify that listmailcapfiles() returns a list of strings that is of
# non-zero length.
# non-zero length.
mcfiles
=
mailcap
.
listmailcapfiles
()
mcfiles
=
mailcap
.
listmailcapfiles
()
self
.
assertTrue
(
isinstance
(
mcfiles
,
list
))
self
.
assertIsInstance
(
mcfiles
,
list
)
self
.
assertTrue
(
all
([
isinstance
(
m
,
str
)
for
m
in
mcfiles
]))
for
m
in
mcfiles
:
self
.
assertIsInstance
(
m
,
str
)
with
test
.
support
.
EnvironmentVarGuard
()
as
env
:
with
test
.
support
.
EnvironmentVarGuard
()
as
env
:
# According to RFC 1524, if MAILCAPS env variable exists, use that
# According to RFC 1524, if MAILCAPS env variable exists, use that
# and only that.
# and only that.
...
@@ -111,15 +124,16 @@ class GetcapsTest(unittest.TestCase):
...
@@ -111,15 +124,16 @@ class GetcapsTest(unittest.TestCase):
def
test_system_mailcap
(
self
):
def
test_system_mailcap
(
self
):
# Test mailcap.getcaps() with mailcap file(s) on system, if any.
# Test mailcap.getcaps() with mailcap file(s) on system, if any.
caps
=
mailcap
.
getcaps
()
caps
=
mailcap
.
getcaps
()
self
.
assert
True
(
isinstance
(
caps
,
dict
)
)
self
.
assert
IsInstance
(
caps
,
dict
)
mailcapfiles
=
mailcap
.
listmailcapfiles
()
mailcapfiles
=
mailcap
.
listmailcapfiles
()
existingmcfiles
=
[
mcf
for
mcf
in
mailcapfiles
if
os
.
path
.
exists
(
mcf
)]
existingmcfiles
=
[
mcf
for
mcf
in
mailcapfiles
if
os
.
path
.
exists
(
mcf
)]
if
existingmcfiles
:
if
existingmcfiles
:
# At least 1 mailcap file exists, so test that.
# At least 1 mailcap file exists, so test that.
for
(
k
,
v
)
in
caps
.
items
():
for
(
k
,
v
)
in
caps
.
items
():
self
.
assertTrue
(
isinstance
(
k
,
str
))
self
.
assertIsInstance
(
k
,
str
)
self
.
assertTrue
(
isinstance
(
v
,
list
))
self
.
assertIsInstance
(
v
,
list
)
self
.
assertTrue
(
all
([
isinstance
(
e
,
dict
)
for
e
in
v
]))
for
e
in
v
:
self
.
assertIsInstance
(
e
,
dict
)
else
:
else
:
# No mailcap files on system. getcaps() should return empty dict.
# No mailcap files on system. getcaps() should return empty dict.
self
.
assertEqual
({},
caps
)
self
.
assertEqual
({},
caps
)
...
@@ -134,15 +148,19 @@ class FindmatchTest(unittest.TestCase):
...
@@ -134,15 +148,19 @@ class FindmatchTest(unittest.TestCase):
fname
=
"foo.txt"
fname
=
"foo.txt"
plist
=
[
"access-type=default"
,
"name=john"
,
"site=python.org"
,
plist
=
[
"access-type=default"
,
"name=john"
,
"site=python.org"
,
"directory=/tmp"
,
"mode=foo"
,
"server=bar"
]
"directory=/tmp"
,
"mode=foo"
,
"server=bar"
]
audio_basic_entry
=
{
'edit'
:
'audiocompose %s'
,
audio_basic_entry
=
{
'edit'
:
'audiocompose %s'
,
'compose'
:
'audiocompose %s'
,
'compose'
:
'audiocompose %s'
,
'description'
:
'"An audio fragment"'
,
'description'
:
'"An audio fragment"'
,
'view'
:
'showaudio %s'
}
'view'
:
'showaudio %s'
}
audio_entry
=
{
"view"
:
"/usr/local/bin/showaudio %t"
}
audio_entry
=
{
"view"
:
"/usr/local/bin/showaudio %t"
}
video_entry
=
{
'view'
:
'animate %s'
}
video_entry
=
{
'view'
:
'animate %s'
}
message_entry
=
{
'composetyped'
:
'extcompose %s'
,
message_entry
=
{
'composetyped'
:
'extcompose %s'
,
'description'
:
'"A reference to data stored in an external location"'
,
'needsterminal'
:
''
,
'description'
:
'"A reference to data stored in an external location"'
,
'needsterminal'
:
''
,
'view'
:
'showexternal %s %{access-type} %{name} %{site} %{directory} %{mode} %{server}'
}
'view'
:
'showexternal %s %{access-type} %{name} %{site} %{directory} %{mode} %{server}'
}
# test case: (findmatch args, findmatch keyword args, expected output)
# test case: (findmatch args, findmatch keyword args, expected output)
# positional args: caps, MIMEtype
# positional args: caps, MIMEtype
...
...
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