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
c0b2b727
Commit
c0b2b727
authored
Nov 18, 2003
by
Jack Jansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test the applesingle decoder.
parent
c19c5a62
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
72 additions
and
0 deletions
+72
-0
Lib/test/test_applesingle.py
Lib/test/test_applesingle.py
+72
-0
No files found.
Lib/test/test_applesingle.py
0 → 100644
View file @
c0b2b727
# Copyright (C) 2003 Python Software Foundation
import
unittest
import
macostools
import
Carbon.File
import
MacOS
import
os
import
sys
from
test
import
test_support
import
struct
import
applesingle
AS_MAGIC
=
0x00051600
AS_VERSION
=
0x00020000
dataforkdata
=
'hello
\
r
\
0
world
\
n
'
resourceforkdata
=
'goodbye
\
n
cruel
\
0
world
\
r
'
applesingledata
=
struct
.
pack
(
"ll16sh"
,
AS_MAGIC
,
AS_VERSION
,
"foo"
,
2
)
+
\
struct
.
pack
(
"llllll"
,
1
,
50
,
len
(
dataforkdata
),
2
,
50
+
len
(
dataforkdata
),
len
(
resourceforkdata
))
+
\
dataforkdata
+
\
resourceforkdata
TESTFN2
=
test_support
.
TESTFN
+
'2'
class
TestApplesingle
(
unittest
.
TestCase
):
def
setUp
(
self
):
fp
=
open
(
test_support
.
TESTFN
,
'w'
)
fp
.
write
(
applesingledata
)
fp
.
close
()
def
tearDown
(
self
):
try
:
os
.
unlink
(
test_support
.
TESTFN
)
except
:
pass
try
:
os
.
unlink
(
TESTFN2
)
except
:
pass
def
compareData
(
self
,
isrf
,
data
):
if
isrf
:
fp
=
MacOS
.
openrf
(
TESTFN2
,
'*rb'
)
else
:
fp
=
open
(
TESTFN2
,
'rb'
)
filedata
=
fp
.
read
(
1000
)
self
.
assertEqual
(
data
,
filedata
)
def
test_applesingle
(
self
):
try
:
os
.
unlink
(
TESTFN2
)
except
:
pass
applesingle
.
decode
(
test_support
.
TESTFN
,
TESTFN2
)
self
.
compareData
(
False
,
dataforkdata
)
self
.
compareData
(
True
,
resourceforkdata
)
def
test_applesingle_resonly
(
self
):
try
:
os
.
unlink
(
TESTFN2
)
except
:
pass
applesingle
.
decode
(
test_support
.
TESTFN
,
TESTFN2
,
resonly
=
True
)
self
.
compareData
(
False
,
resourceforkdata
)
def
test_main
():
test_support
.
run_unittest
(
TestApplesingle
)
if
__name__
==
'__main__'
:
test_main
()
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