##// END OF EJS Templates
Work around a bug in setting and getting the mtime in python 2...
Work around a bug in setting and getting the mtime in python 2 See http://bugs.python.org/issue12904. Basically, we can get the mtime in nanosecond precision, but only set it in microsecond precision. This means that the shutil.copy2 will not set the destination's mtime to exactly the same mtime as our source. The end result is that we can *always* end up copying the extension because the source always appears newer. We add a microsecond of fudge time when checking to see if the source is newer than the destination to get around this. This bug is fixed in Python 3.3+, I believe.

File last commit:

r15442:0073d6a2
r20080:52d92404
Show More
test_notebookapp.py
74 lines | 2.5 KiB | text/x-python | PythonLexer
/ IPython / html / tests / test_notebookapp.py
MinRK
test that `-h` and `--help-all` work for various IPython entry points...
r12354 """Test NotebookApp"""
#-----------------------------------------------------------------------------
# Copyright (C) 2013 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
MinRK
capture logging in a few tests...
r15442 import logging
MinRK
reorganize who knows what about paths...
r15420 import os
from tempfile import NamedTemporaryFile
MinRK
test that `-h` and `--help-all` work for various IPython entry points...
r12354 import nose.tools as nt
MinRK
reorganize who knows what about paths...
r15420 from IPython.utils.tempdir import TemporaryDirectory
from IPython.utils.traitlets import TraitError
MinRK
test that `-h` and `--help-all` work for various IPython entry points...
r12354 import IPython.testing.tools as tt
Thomas Kluyver
Test for writing and removing server info files
r14064 from IPython.html import notebookapp
MinRK
reorganize who knows what about paths...
r15420 NotebookApp = notebookapp.NotebookApp
MinRK
test that `-h` and `--help-all` work for various IPython entry points...
r12354
#-----------------------------------------------------------------------------
# Test functions
#-----------------------------------------------------------------------------
def test_help_output():
"""ipython notebook --help-all works"""
tt.help_all_output_test('notebook')
Thomas Kluyver
Test for writing and removing server info files
r14064 def test_server_info_file():
MinRK
capture logging in a few tests...
r15442 nbapp = NotebookApp(profile='nbserver_file_test', log=logging.getLogger())
Thomas Kluyver
Test for writing and removing server info files
r14064 def get_servers():
Thomas Kluyver
Command line entry point to list running notebook servers
r14177 return list(notebookapp.list_running_servers(profile='nbserver_file_test'))
Thomas Kluyver
Test for writing and removing server info files
r14064 nbapp.initialize(argv=[])
nbapp.write_server_info_file()
servers = get_servers()
nt.assert_equal(len(servers), 1)
nt.assert_equal(servers[0]['port'], nbapp.port)
nt.assert_equal(servers[0]['url'], nbapp.connection_url)
nbapp.remove_server_info_file()
nt.assert_equal(get_servers(), [])
# The ENOENT error should be silenced.
MinRK
reorganize who knows what about paths...
r15420 nbapp.remove_server_info_file()
def test_nb_dir():
with TemporaryDirectory() as td:
app = NotebookApp(notebook_dir=td)
nt.assert_equal(app.notebook_dir, td)
MinRK
don't create notebook_dir if it doesn't exist
r15423 def test_no_create_nb_dir():
MinRK
reorganize who knows what about paths...
r15420 with TemporaryDirectory() as td:
nbdir = os.path.join(td, 'notebooks')
MinRK
don't create notebook_dir if it doesn't exist
r15423 app = NotebookApp()
with nt.assert_raises(TraitError):
app.notebook_dir = nbdir
MinRK
reorganize who knows what about paths...
r15420
def test_missing_nb_dir():
with TemporaryDirectory() as td:
nbdir = os.path.join(td, 'notebook', 'dir', 'is', 'missing')
app = NotebookApp()
with nt.assert_raises(TraitError):
app.notebook_dir = nbdir
def test_invalid_nb_dir():
with NamedTemporaryFile() as tf:
app = NotebookApp()
with nt.assert_raises(TraitError):
app.notebook_dir = tf