mirror of
https://github.com/jupyter/notebook.git
synced 2025-02-05 12:19:58 +08:00
Copy file metadata in atomic save
Closes gh-6405
This commit is contained in:
parent
052f990333
commit
9bde43a7fd
@ -16,6 +16,7 @@ from __future__ import absolute_import
|
||||
|
||||
import io as stdlib_io
|
||||
import os.path
|
||||
import stat
|
||||
import sys
|
||||
|
||||
from subprocess import Popen, PIPE
|
||||
@ -134,6 +135,10 @@ def test_atomic_writing():
|
||||
f1 = os.path.join(td, 'penguin')
|
||||
with stdlib_io.open(f1, 'w') as f:
|
||||
f.write(u'Before')
|
||||
|
||||
if os.name != 'nt':
|
||||
os.chmod(f1, 0o701)
|
||||
orig_mode = stat.S_IMODE(os.stat(f1).st_mode)
|
||||
|
||||
with nt.assert_raises(CustomExc):
|
||||
with atomic_writing(f1) as f:
|
||||
@ -149,3 +154,7 @@ def test_atomic_writing():
|
||||
|
||||
with stdlib_io.open(f1, 'r') as f:
|
||||
nt.assert_equal(f.read(), u'Overwritten')
|
||||
|
||||
if os.name != 'nt':
|
||||
mode = stat.S_IMODE(os.stat(f1).st_mode)
|
||||
nt.assert_equal(mode, orig_mode)
|
||||
|
Loading…
Reference in New Issue
Block a user