def test_paired_paths_windows_no_subfolder(): nb_file = "C:\\Users\\notebooks\\notebooks\\nb.ipynb" formats = "notebooks///ipynb,scripts///py" with mock.patch("os.path.sep", "\\"): assert base_path(nb_file, "notebooks///ipynb") == "C:\\Users\\notebooks\\//nb" paired_paths(nb_file, "notebooks///ipynb", formats)
def test_base_path_in_tree_from_non_root_no_subfolder(): nb_file = "/parent/notebooks/wrap_markdown.ipynb" formats = "notebooks///ipynb,scripts///py:percent" fmt = "notebooks///ipynb" assert base_path(nb_file, fmt) == "/parent///wrap_markdown" paired_paths(nb_file, fmt, formats)
def test_base_path_in_tree_from_non_root(): fmt = long_form_one_format("scripts///py") assert ( base_path("/parent_folder/scripts/subfolder/test.py", fmt=fmt) == "/parent_folder///subfolder/test" )
def test_base_path_dotdot(): fmt = long_form_one_format("../scripts//py") assert base_path("scripts/test.py", fmt=fmt) == "scripts/test"
def test_base_path(): fmt = long_form_one_format("dir/prefix_/ipynb") assert base_path("dir/prefix_NAME.ipynb", fmt) == "NAME" with pytest.raises(InconsistentPath): base_path("dir/incorrect_prefix_NAME.ipynb", fmt)
def test_base_path(): fmt = long_form_one_format('dir/prefix_/ipynb') assert base_path('dir/prefix_NAME.ipynb', fmt) == 'NAME' with pytest.raises(InconsistentPath): base_path('dir/incorrect_prefix_NAME.ipynb', fmt)