diff --git a/notebook/bundler/tests/test_bundler_tools.py b/notebook/bundler/tests/test_bundler_tools.py index 0c93c440c..855cf978f 100644 --- a/notebook/bundler/tests/test_bundler_tools.py +++ b/notebook/bundler/tests/test_bundler_tools.py @@ -84,12 +84,12 @@ b/ def test_glob_dir(self): '''Should expand to single file in the resources/ subfolder.''' - self.assertIn('resources/empty.ipynb', + self.assertIn(os.path.join('resources', 'empty.ipynb'), tools.expand_references(HERE, ['resources/empty.ipynb'])) def test_glob_subdir(self): '''Should expand to all files in the resources/ subfolder.''' - self.assertIn('resources/empty.ipynb', + self.assertIn(os.path.join('resources', 'empty.ipynb'), tools.expand_references(HERE, ['resources/'])) def test_glob_splat(self): @@ -101,24 +101,24 @@ b/ def test_glob_splatsplat_in_middle(self): '''Should expand to test_file.txt deep under this test/ directory.''' globs = tools.expand_references(HERE, ['resources/**/test_file.txt']) - self.assertIn('resources/subdir/test_file.txt', globs, globs) + self.assertIn(os.path.join('resources', 'subdir', 'test_file.txt'), globs, globs) def test_glob_splatsplat_trailing(self): - '''Should expand to all descendants of this test/ directory.''' + '''Should expand to all descendants of this test/ directory.''' globs = tools.expand_references(HERE, ['resources/**']) - self.assertIn('resources/empty.ipynb', globs, globs) - self.assertIn('resources/subdir/test_file.txt', globs, globs) + self.assertIn(os.path.join('resources', 'empty.ipynb'), globs, globs) + self.assertIn(os.path.join('resources', 'subdir', 'test_file.txt'), globs, globs) def test_glob_splatsplat_leading(self): '''Should expand to test_file.txt under any path.''' globs = tools.expand_references(HERE, ['**/test_file.txt']) - self.assertIn('resources/subdir/test_file.txt', globs, globs) - self.assertIn('resources/another_subdir/test_file.txt', globs, globs) + self.assertIn(os.path.join('resources', 'subdir', 'test_file.txt'), globs, globs) + self.assertIn(os.path.join('resources', 'another_subdir', 'test_file.txt'), globs, globs) def test_copy_filelist(self): '''Should copy select files from source to destination''' globs = tools.expand_references(HERE, ['**/test_file.txt']) tools.copy_filelist(HERE, self.tmp, globs) - self.assertTrue(os.path.isfile(os.path.join(self.tmp, 'resources/subdir/test_file.txt'))) - self.assertTrue(os.path.isfile(os.path.join(self.tmp, 'resources/another_subdir/test_file.txt'))) - self.assertFalse(os.path.isfile(os.path.join(self.tmp, 'resources/empty.ipynb'))) + self.assertTrue(os.path.isfile(os.path.join(self.tmp, 'resources', 'subdir', 'test_file.txt'))) + self.assertTrue(os.path.isfile(os.path.join(self.tmp, 'resources', 'another_subdir', 'test_file.txt'))) + self.assertFalse(os.path.isfile(os.path.join(self.tmp, 'resources', 'empty.ipynb'))) diff --git a/notebook/bundler/tools.py b/notebook/bundler/tools.py index 82fbc67e0..cdf3556ac 100644 --- a/notebook/bundler/tools.py +++ b/notebook/bundler/tools.py @@ -11,8 +11,8 @@ import glob def get_file_references(abs_nb_path, version): """Gets a list of files referenced either in Markdown fenced code blocks - or in HTML comments from the notebook. Expands patterns expressed in - gitignore syntax (https://git-scm.com/docs/gitignore). Returns the + or in HTML comments from the notebook. Expands patterns expressed in + gitignore syntax (https://git-scm.com/docs/gitignore). Returns the fully expanded list of filenames relative to the notebook dirname. Parameters @@ -21,7 +21,7 @@ def get_file_references(abs_nb_path, version): Absolute path of the notebook on disk version: int Version of the notebook document format to use - + Returns ------- list @@ -41,7 +41,7 @@ def get_reference_patterns(abs_nb_path, version): Absolute path of the notebook on disk version: int Version of the notebook document format to use - + Returns ------- list @@ -66,7 +66,7 @@ def get_cell_reference_patterns(cell): !foo/bar ``` - or + or