Skip to content

Commit d11b923

Browse files
committed
Test data paths were added multiple times to cdl.utils.tests.TST_PATH
Fix #84
1 parent 9e6c4b5 commit d11b923

File tree

5 files changed

+40
-9
lines changed

5 files changed

+40
-9
lines changed

.vscode/launch.json

+3
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@
8484
],
8585
"env": {
8686
// "DEBUG": "1",
87+
// The `CDL_DATA` environment variable is set here just for checking
88+
// that the data path is not added twice to the test data path list:
89+
"CDL_DATA": "${workspaceFolder}/cdl/data/tests",
8790
"LANG": "en",
8891
"QT_COLOR_MODE": "light",
8992
}

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
See DataLab [roadmap page](https://datalab-platform.com/en/contributing/roadmap.html) for future and past milestones.
44

5+
## DataLab Version 0.16.3 ##
6+
7+
🛠️ Bug fixes:
8+
9+
* Fixed [Issue #84](https://github.com./DataLab-Platform/DataLab/issues/84) - Build issues with V0.16.1: `signal` name conflict, ...
10+
* This issue was intended to be fixed in version 0.16.2, but the fix was not complete
11+
* Thanks to [@rolandmas](https://github.com./rolandmas) for reporting the issue and for the help in investigating the problem and testing the fix
12+
* Fixed [Issue #85](https://github.com./DataLab-Platform/DataLab/issues/85) - Test data paths may be added multiple times to `cdl.utils.tests.TST_PATH`
13+
* This issue is related to [Issue #84](https://github.com./DataLab-Platform/DataLab/issues/84)
14+
* Adding the test data paths multiple times to `cdl.utils.tests.TST_PATH` was causing the test data to be loaded multiple times, which lead to some tests failing (a simple workaround was added to V0.16.2: this issue is now fixed)
15+
* Thanks again to [@rolandmas](https://github.com./rolandmas) for reporting the issue in the context of the Debian packaging
16+
517
## DataLab Version 0.16.2 ##
618

719
This release requires PlotPy v2.4.0 or later, which brings the following bug fixes and new features:

cdl/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import os
1515

16-
__version__ = "0.16.2"
16+
__version__ = "0.16.3"
1717
__docurl__ = __homeurl__ = "https://datalab-platform.com/"
1818
__supporturl__ = "https://github.com./DataLab-Platform/DataLab/issues/new/choose"
1919

cdl/tests/__init__.py

-6
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@
2828
from cdl.utils import qthelpers as qth
2929
from cdl.utils import tests
3030

31-
# Add test data files and folders pointed by `CDL_DATA` environment variable:
32-
tests.add_test_path_from_env("CDL_DATA")
33-
34-
35-
# TODO: [P2] Documentation: add more screenshots from tests
36-
3731

3832
@contextmanager
3933
def cdltest_app_context(

cdl/utils/tests.py

+24-2
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,33 @@
2626
TST_PATH = []
2727

2828

29+
def add_test_path(path: str) -> None:
30+
"""Appends test data path, after normalizing it and making it absolute.
31+
Do nothing if the path is already in the list.
32+
33+
Args:
34+
Path to add to the list of test data paths
35+
36+
Raises:
37+
FileNotFoundError: if the path does not exist
38+
"""
39+
path = osp.abspath(osp.normpath(path))
40+
if path not in TST_PATH:
41+
if not osp.exists(path):
42+
raise FileNotFoundError(f"Test data path does not exist: {path}")
43+
TST_PATH.append(path)
44+
45+
2946
def add_test_path_from_env(envvar: str) -> None:
3047
"""Appends test data path from environment variable (fails silently)"""
3148
# Note: this function is used in third-party plugins
3249
path = os.environ.get(envvar)
3350
if path:
34-
TST_PATH.append(path)
51+
add_test_path(path)
52+
53+
54+
# Add test data files and folders pointed by `CDL_DATA` environment variable:
55+
add_test_path_from_env("CDL_DATA")
3556

3657

3758
def add_test_module_path(modname: str, relpath: str) -> None:
@@ -43,9 +64,10 @@ def add_test_module_path(modname: str, relpath: str) -> None:
4364
modname must be the name of an already imported module as found in
4465
sys.modules
4566
"""
46-
TST_PATH.append(get_module_data_path(modname, relpath=relpath))
67+
add_test_path(get_module_data_path(modname, relpath=relpath))
4768

4869

70+
# Add test data files and folders for the DataLab module:
4971
add_test_module_path(MOD_NAME, osp.join("data", "tests"))
5072

5173

0 commit comments

Comments
 (0)