##// END OF EJS Templates
Merge pull request #3158 from minrk/autosave...
Merge pull request #3158 from minrk/autosave Add autosaving to the notebook, while retaining manual checkpoint creation. Autosave will perodically save the notebook, with a default interval of two minutes. This interval is configurable, and the system will automatically back off the frequency if it detects that the save operation takes too long. This can be the case if working remotely over a slow link, so this will automatically conserve bandwidth. The manual save operation remains available and bound to the same keys, but now it causes the creation of a separate checkpoint, which is stored in a hidden directory called `.ipynb_checkpoints`. This provides users a poor-man's version control with a single revert point and the ability to safely experiment with potentially destructive changes to a notebook without concern that the autosave operation may clobber their file on disk. See [IPEP 15](https://github.com/ipython/ipython/wiki/IPEP-15%3A-Autosaving-the-IPython-Notebook) for details of the proposal.

File last commit:

r8191:c01cdaf1
r10521:b69eb67e merge
Show More
test_nbmanager.py
34 lines | 1.1 KiB | text/x-python | PythonLexer
"""Tests for the notebook manager."""
import os
from unittest import TestCase
from tempfile import NamedTemporaryFile
from IPython.utils.tempdir import TemporaryDirectory
from IPython.utils.traitlets import TraitError
from IPython.frontend.html.notebook.filenbmanager import FileNotebookManager
class TestNotebookManager(TestCase):
def test_nb_dir(self):
with TemporaryDirectory() as td:
km = FileNotebookManager(notebook_dir=td)
self.assertEqual(km.notebook_dir, td)
def test_create_nb_dir(self):
with TemporaryDirectory() as td:
nbdir = os.path.join(td, 'notebooks')
km = FileNotebookManager(notebook_dir=nbdir)
self.assertEqual(km.notebook_dir, nbdir)
def test_missing_nb_dir(self):
with TemporaryDirectory() as td:
nbdir = os.path.join(td, 'notebook', 'dir', 'is', 'missing')
self.assertRaises(TraitError, FileNotebookManager, notebook_dir=nbdir)
def test_invalid_nb_dir(self):
with NamedTemporaryFile() as tf:
self.assertRaises(TraitError, FileNotebookManager, notebook_dir=tf.name)