-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
test_base.py
56 lines (46 loc) · 1.81 KB
/
test_base.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
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright (c) 2009- Spyder Project Contributors
#
# Distributed under the terms of the MIT License
# (see spyder/__init__.py for details)
# -----------------------------------------------------------------------------
"""
Tests for the spyder.config.base module.
"""
# Standard library imports
import os
import os.path as osp
try:
from importlib import reload
except ImportError: # A builtin on Python 2
pass
# Third party imports
import pytest
# Local imports
import spyder.config.base
# ============================================================================
# ---- Tests
# ============================================================================
def test_is_stable_version():
"""Test that stable and non-stable versions are recognized correctly."""
for stable_version in ['3.3.0', '2', ('0', '5')]:
assert spyder.config.base.is_stable_version(stable_version)
for not_stable_version in ['4.0.0b1', '3.3.2.dev0',
'beta', ('2', '0', 'alpha')]:
assert not spyder.config.base.is_stable_version(not_stable_version)
@pytest.mark.parametrize('use_dev_config_dir', [True, False])
def test_get_conf_path(monkeypatch, use_dev_config_dir):
"""Test that the config dir path is set under dev and release builds."""
monkeypatch.setenv('SPYDER_USE_DEV_CONFIG_DIR', str(use_dev_config_dir))
monkeypatch.setenv('SPYDER_PYTEST', '')
reload(spyder.config.base)
conf_path = spyder.config.base.get_conf_path()
assert conf_path
assert ((osp.basename(conf_path).split('-')[-1] == 'dev')
== use_dev_config_dir)
assert osp.isdir(conf_path)
monkeypatch.undo()
reload(spyder.config.base)
if __name__ == '__main__':
pytest.main()