Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
10882f6f
Kaydet (Commit)
10882f6f
authored
Ock 28, 2003
tarafından
Jack Jansen
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Finally created the first two tests for MacPython modules: macfs and
macostools.
üst
fe8d84d5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
138 additions
and
0 deletions
+138
-0
test_macfs.py
Lib/test/test_macfs.py
+69
-0
test_macostools.py
Lib/test/test_macostools.py
+69
-0
No files found.
Lib/test/test_macfs.py
0 → 100644
Dosyayı görüntüle @
10882f6f
# Copyright (C) 2003 Python Software Foundation
import
unittest
import
macfs
import
os
import
tempfile
from
test
import
test_support
class
TestMacfs
(
unittest
.
TestCase
):
def
setUp
(
self
):
fp
=
open
(
test_support
.
TESTFN
,
'w'
)
fp
.
write
(
'hello world
\n
'
)
fp
.
close
()
def
tearDown
(
self
):
try
:
os
.
unlink
(
test_support
.
TESTFN
)
except
:
pass
def
test_fsspec
(
self
):
fss
=
macfs
.
FSSpec
(
test_support
.
TESTFN
)
self
.
assertEqual
(
os
.
path
.
abspath
(
test_support
.
TESTFN
),
fss
.
as_pathname
())
def
test_fsref
(
self
):
fsr
=
macfs
.
FSRef
(
test_support
.
TESTFN
)
self
.
assertEqual
(
os
.
path
.
abspath
(
test_support
.
TESTFN
),
fsr
.
as_pathname
())
def
test_coercion
(
self
):
fss
=
macfs
.
FSSpec
(
test_support
.
TESTFN
)
fsr
=
macfs
.
FSRef
(
test_support
.
TESTFN
)
fss2
=
fsr
.
as_fsspec
()
fsr2
=
fss
.
as_fsref
()
self
.
assertEqual
(
fss
.
as_pathname
(),
fss2
.
as_pathname
())
self
.
assertEqual
(
fsr
.
as_pathname
(),
fsr2
.
as_pathname
())
def
test_dates
(
self
):
import
time
fss
=
macfs
.
FSSpec
(
test_support
.
TESTFN
)
now
=
int
(
time
.
time
())
fss
.
SetDates
(
now
,
now
-
1
,
now
-
2
)
dates
=
fss
.
GetDates
()
self
.
assertEqual
(
dates
,
(
now
,
now
-
1
,
now
-
2
))
def
test_ctor_type
(
self
):
fss
=
macfs
.
FSSpec
(
test_support
.
TESTFN
)
fss
.
SetCreatorType
(
'Pyth'
,
'TEXT'
)
filecr
,
filetp
=
fss
.
GetCreatorType
()
self
.
assertEqual
((
filecr
,
filetp
),
(
'Pyth'
,
'TEXT'
))
def
test_alias
(
self
):
fss
=
macfs
.
FSSpec
(
test_support
.
TESTFN
)
alias
=
fss
.
NewAlias
()
fss2
,
changed
=
alias
.
Resolve
()
self
.
assertEqual
(
changed
,
0
)
self
.
assertEqual
(
fss
.
as_pathname
(),
fss2
.
as_pathname
())
def
test_fss_alias
(
self
):
fss
=
macfs
.
FSSpec
(
test_support
.
TESTFN
)
def
test_main
():
test_support
.
run_unittest
(
TestMacfs
)
if
__name__
==
'__main__'
:
test_main
()
Lib/test/test_macostools.py
0 → 100644
Dosyayı görüntüle @
10882f6f
# Copyright (C) 2003 Python Software Foundation
import
unittest
import
macostools
import
MacOS
import
os
import
tempfile
from
test
import
test_support
TESTFN2
=
test_support
.
TESTFN
+
'2'
class
TestMacostools
(
unittest
.
TestCase
):
def
setUp
(
self
):
fp
=
open
(
test_support
.
TESTFN
,
'w'
)
fp
.
write
(
'hello world
\n
'
)
fp
.
close
()
rfp
=
MacOS
.
openrf
(
test_support
.
TESTFN
,
'*wb'
)
rfp
.
write
(
'goodbye world
\n
'
)
rfp
.
close
()
def
tearDown
(
self
):
try
:
os
.
unlink
(
test_support
.
TESTFN
)
except
:
pass
try
:
os
.
unlink
(
TESTFN2
)
except
:
pass
def
compareData
(
self
):
fp
=
open
(
test_support
.
TESTFN
,
'r'
)
data1
=
fp
.
read
()
fp
.
close
()
fp
=
open
(
TESTFN2
,
'r'
)
data2
=
fp
.
read
()
fp
.
close
()
if
data1
!=
data2
:
return
'Data forks differ'
rfp
=
MacOS
.
openrf
(
test_support
.
TESTFN
,
'*rb'
)
data1
=
rfp
.
read
(
1000
)
rfp
.
close
()
rfp
=
MacOS
.
openrf
(
TESTFN2
,
'*rb'
)
data2
=
rfp
.
read
(
1000
)
rfp
.
close
()
if
data1
!=
data2
:
return
'Resource forks differ'
return
''
def
test_touched
(
self
):
# This really only tests that nothing unforeseen happens.
macostools
.
touched
(
test_support
.
TESTFN
)
def
test_copy
(
self
):
try
:
os
.
unlink
(
TESTFN2
)
except
:
pass
macostools
.
copy
(
test_support
.
TESTFN
,
TESTFN2
)
self
.
assertEqual
(
self
.
compareData
(),
''
)
def
test_main
():
test_support
.
run_unittest
(
TestMacostools
)
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