-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
test_misc.py
65 lines (53 loc) · 1.76 KB
/
test_misc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# -*- coding: utf-8 -*-
#
# Copyright © Spyder Project Contributors
# Licensed under the terms of the MIT License
#
"""
Tests for misc.py
"""
# Standard library imports
import os
# Test library imports
import pytest
# Local imports
from spyder.utils.misc import (
get_common_path, add_pathlist_to_PYTHONPATH
)
def test_get_common_path():
"""Test getting the common path."""
if os.name == 'nt':
assert get_common_path([
'D:\\Python\\spyder-v21\\spyder\\widgets',
'D:\\Python\\spyder\\spyder\\utils',
'D:\\Python\\spyder\\spyder\\widgets',
'D:\\Python\\spyder-v21\\spyder\\utils',
]) == 'D:\\Python'
else:
assert get_common_path([
'/Python/spyder-v21/spyder.widgets',
'/Python/spyder/spyder.utils',
'/Python/spyder/spyder.widgets',
'/Python/spyder-v21/spyder.utils',
]) == '/Python'
@pytest.mark.parametrize("drop_env", [True, False])
def test_add_pathlist_to_PYTHONPATH(drop_env):
"""Test for add_pathlist_to_PYTHONPATH."""
pathlist = ['test123', 'test456']
if drop_env:
env = []
expected = ['PYTHONPATH=' + pathlist[0] + os.pathsep + pathlist[1]]
else:
env = ['PYTHONPATH=test0']
expected = [
'PYTHONPATH=' +
pathlist[0] +
os.pathsep +
pathlist[1] +
os.pathsep +
'test0'
]
add_pathlist_to_PYTHONPATH(env, pathlist, drop_env=drop_env)
assert env == expected
if __name__ == "__main__":
pytest.main()