Skip to content
Snippets Groups Projects
Commit 34dc48a5 authored by Joscha Schmiedt's avatar Joscha Schmiedt
Browse files

TST: Make file paths Windows-compatible

parent e5d75eb6
Branches
Tags
2 merge requests!217TST: Make NamedTemporaryFiles Windows-compatible,!207Resolve "Failing unit tests on Windows"
...@@ -824,9 +824,9 @@ def test_restricted_path(create_mock): ...@@ -824,9 +824,9 @@ def test_restricted_path(create_mock):
def test_split_restricted_path(): def test_split_restricted_path():
assert ["el"] == split_restricted_path("/el") assert ["el"] == split_restricted_path(os.path.sep + "el")
assert ["el"] == split_restricted_path("/el/") assert ["el"] == split_restricted_path(os.path.sep + "el" + os.path.sep)
assert ["el", "el"] == split_restricted_path("/el/el") assert ["el", "el"] == split_restricted_path(os.path.sep + "el" + os.path.sep + "el")
# Filter the warning because we want to have it here and this way it does not hinder running # Filter the warning because we want to have it here and this way it does not hinder running
......
...@@ -30,7 +30,7 @@ from functools import partial ...@@ -30,7 +30,7 @@ from functools import partial
from pathlib import Path from pathlib import Path
from tempfile import NamedTemporaryFile from tempfile import NamedTemporaryFile
from unittest.mock import MagicMock, Mock, patch from unittest.mock import MagicMock, Mock, patch
import os
import linkahead as db import linkahead as db
import pytest import pytest
import yaml import yaml
...@@ -110,7 +110,7 @@ def test_record_structure_generation(): ...@@ -110,7 +110,7 @@ def test_record_structure_generation():
assert len(subc[1]) == 0 assert len(subc[1]) == 0
# The data analysis node creates one variable for the node itself: # The data analysis node creates one variable for the node itself:
assert subd[0]["DataAnalysis"] == "examples_article/DataAnalysis" assert subd[0]["DataAnalysis"] == os.path.join("examples_article", "DataAnalysis")
assert subc[0]["DataAnalysis"] is False assert subc[0]["DataAnalysis"] is False
subd = dbt.debug_tree[dircheckstr("DataAnalysis", "2020_climate-model-predict")] subd = dbt.debug_tree[dircheckstr("DataAnalysis", "2020_climate-model-predict")]
...@@ -128,9 +128,9 @@ def test_record_structure_generation(): ...@@ -128,9 +128,9 @@ def test_record_structure_generation():
assert subd[0]["identifier"] == "climate-model-predict" assert subd[0]["identifier"] == "climate-model-predict"
assert subd[0]["Project"].__class__ == db.Record assert subd[0]["Project"].__class__ == db.Record
assert subd[0]["DataAnalysis"] == "examples_article/DataAnalysis" assert subd[0]["DataAnalysis"] == os.path.join("examples_article" , "DataAnalysis")
assert subc[0]["DataAnalysis"] is True assert subc[0]["DataAnalysis"] is True
assert subd[0]["project_dir"] == "examples_article/DataAnalysis/2020_climate-model-predict" assert subd[0]["project_dir"] == os.path.join("examples_article", "DataAnalysis", "2020_climate-model-predict")
assert subc[0]["project_dir"] is False assert subc[0]["project_dir"] is False
# Check the copy flags for the first level in the hierarchy: # Check the copy flags for the first level in the hierarchy:
......
...@@ -20,22 +20,22 @@ ...@@ -20,22 +20,22 @@
# #
import pytest import pytest
from os.path import sep
from caoscrawler.crawl import split_restricted_path from caoscrawler.crawl import split_restricted_path
from caoscrawler.utils import MissingImport, get_shared_resource_link from caoscrawler.utils import MissingImport, get_shared_resource_link
def test_split_restricted_path(): def test_split_restricted_path():
assert split_restricted_path("") == [] assert split_restricted_path("") == []
assert split_restricted_path("/") == [] assert split_restricted_path(f"{sep}") == []
assert split_restricted_path("test/") == ["test"] assert split_restricted_path(f"test{sep}") == ["test"]
assert split_restricted_path("/test/") == ["test"] assert split_restricted_path(f"{sep}test{sep}") == ["test"]
assert split_restricted_path("test/bla") == ["test", "bla"] assert split_restricted_path(f"test{sep}bla") == ["test", "bla"]
assert split_restricted_path("/test/bla") == ["test", "bla"] assert split_restricted_path(f"{sep}test{sep}bla") == ["test", "bla"]
assert split_restricted_path("/test1/test2/bla") == ["test1", "test2", "bla"] assert split_restricted_path(f"{sep}test1{sep}test2{sep}bla") == ["test1", "test2", "bla"]
assert split_restricted_path("/test//bla") == ["test", "bla"] assert split_restricted_path(f"{sep}test{sep}{sep}bla") == ["test", "bla"]
assert split_restricted_path("//test/bla") == ["test", "bla"] assert split_restricted_path(f"{sep}{sep}test{sep}bla") == ["test", "bla"]
assert split_restricted_path("///test//bla////") == ["test", "bla"] assert split_restricted_path(f"{sep}{sep}{sep}test{sep}{sep}bla{sep}{sep}{sep}{sep}") == ["test", "bla"]
def test_dummy_class(): def test_dummy_class():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment