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
405faed5
Commit
405faed5
authored
Dec 25, 2012
by
Andrew Svetlov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test coverage for os.removedirs (#16775)
parent
ed30199e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
0 deletions
+46
-0
Lib/test/test_os.py
Lib/test/test_os.py
+46
-0
No files found.
Lib/test/test_os.py
View file @
405faed5
...
...
@@ -634,6 +634,50 @@ class MakedirTests(unittest.TestCase):
os
.
removedirs
(
path
)
class
RemoveDirsTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
os
.
makedirs
(
support
.
TESTFN
)
def
tearDown
(
self
):
support
.
rmtree
(
support
.
TESTFN
)
def
test_remove_all
(
self
):
dira
=
os
.
path
.
join
(
support
.
TESTFN
,
'dira'
)
os
.
mkdir
(
dira
)
dirb
=
os
.
path
.
join
(
dira
,
'dirb'
)
os
.
mkdir
(
dirb
)
os
.
removedirs
(
dirb
)
self
.
assertFalse
(
os
.
path
.
exists
(
dirb
))
self
.
assertFalse
(
os
.
path
.
exists
(
dira
))
self
.
assertFalse
(
os
.
path
.
exists
(
support
.
TESTFN
))
def
test_remove_partial
(
self
):
dira
=
os
.
path
.
join
(
support
.
TESTFN
,
'dira'
)
os
.
mkdir
(
dira
)
dirb
=
os
.
path
.
join
(
dira
,
'dirb'
)
os
.
mkdir
(
dirb
)
with
open
(
os
.
path
.
join
(
dira
,
'file.txt'
),
'w'
)
as
f
:
f
.
write
(
'text'
)
os
.
removedirs
(
dirb
)
self
.
assertFalse
(
os
.
path
.
exists
(
dirb
))
self
.
assertTrue
(
os
.
path
.
exists
(
dira
))
self
.
assertTrue
(
os
.
path
.
exists
(
support
.
TESTFN
))
def
test_remove_nothing
(
self
):
dira
=
os
.
path
.
join
(
support
.
TESTFN
,
'dira'
)
os
.
mkdir
(
dira
)
dirb
=
os
.
path
.
join
(
dira
,
'dirb'
)
os
.
mkdir
(
dirb
)
with
open
(
os
.
path
.
join
(
dirb
,
'file.txt'
),
'w'
)
as
f
:
f
.
write
(
'text'
)
with
self
.
assertRaises
(
OSError
):
os
.
removedirs
(
dirb
)
self
.
assertTrue
(
os
.
path
.
exists
(
dirb
))
self
.
assertTrue
(
os
.
path
.
exists
(
dira
))
self
.
assertTrue
(
os
.
path
.
exists
(
support
.
TESTFN
))
class
DevNullTests
(
unittest
.
TestCase
):
def
test_devnull
(
self
):
with
open
(
os
.
devnull
,
'wb'
)
as
f
:
...
...
@@ -642,6 +686,7 @@ class DevNullTests(unittest.TestCase):
with
open
(
os
.
devnull
,
'rb'
)
as
f
:
self
.
assertEqual
(
f
.
read
(),
b''
)
class
URandomTests
(
unittest
.
TestCase
):
def
test_urandom_length
(
self
):
self
.
assertEqual
(
len
(
os
.
urandom
(
0
)),
0
)
...
...
@@ -1310,6 +1355,7 @@ def test_main():
PidTests
,
LoginTests
,
LinkTests
,
RemoveDirsTests
,
)
if
__name__
==
"__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