Skip to content

Commit

Permalink
Fixed end-to-end autosave test, and made it more robust against other…
Browse files Browse the repository at this point in the history
… engine changes.
  • Loading branch information
Leo Dirac authored and MSeal committed Dec 30, 2019
1 parent 9ed7207 commit 1bd7d02
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,5 @@ binder/*run*.ipynb
# pip generated wheel metadata
pip-wheel-metadata

# VIM swamp files
# VIM swap files
*.swp
16 changes: 11 additions & 5 deletions papermill/tests/test_autosave.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,15 @@ def test_autosave_disable(self):
def test_end2end_autosave_slow_notebook(self):
test_dir = tempfile.mkdtemp()
nb_test_executed_fname = os.path.join(test_dir, 'output_{}'.format(self.notebook_name))

# Count how many times it writes the file w/o autosave
with patch.object(engines, 'write_ipynb') as write_mock:
execute_notebook(self.notebook_path, nb_test_executed_fname, autosave_cell_every=0)
default_write_count = write_mock.call_count

# Turn on autosave and see how many more times it gets saved.
with patch.object(engines, 'write_ipynb') as write_mock:
# This notebook has a cell which takes 2.5 seconds to run
execute_notebook(self.notebook_path, nb_test_executed_fname, autosave_cell_ever=1)
assert (
write_mock.call_count == 4
) # Saves twice normally, and 2x autosave during slow cell.
execute_notebook(self.notebook_path, nb_test_executed_fname, autosave_cell_every=1)
# This notebook has a cell which takes 2.5 seconds to run.
# Autosave every 1 sec should add two more saves.
assert write_mock.call_count == default_write_count + 2

0 comments on commit 1bd7d02

Please sign in to comment.