-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import os | ||
from decompiler.util.closeable_named_temporary_file import CloseableNamedTemporaryFile | ||
|
||
|
||
class TestCloseableNamedTemporaryFile: | ||
def test_usage_after_closing(self): | ||
with CloseableNamedTemporaryFile(mode = "w") as file: | ||
file.write("test") | ||
file.close() | ||
with open(file.name, "r") as reopened_file: | ||
assert reopened_file.read() == "test" | ||
|
||
def test_deletion_with_close(self): | ||
with CloseableNamedTemporaryFile(mode = "w") as file: | ||
file.close() | ||
assert not os.path.exists(file.name) | ||
|
||
def test_deletion_without_close(self): | ||
with CloseableNamedTemporaryFile(mode = "w") as file: | ||
pass | ||
assert not os.path.exists(file.name) | ||
|
||
def test_close_after_delete(self): | ||
with CloseableNamedTemporaryFile(mode = "w") as file: | ||
pass | ||
file.close() |