Skip to content

Commit 950b06a

Browse files
committed
silence deprecation warning for Python 2.6 when testing with Python 2.6
1 parent 04dc49b commit 950b06a

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ matrix:
1919
include:
2020
# also test default configuration with Python 2.6
2121
- python: 2.6
22-
env: LMOD_VERSION=7.8.22
22+
env: LMOD_VERSION=7.8.22 TEST_EASYBUILD_SILENCE_DEPRECATION_WARNINGS=Python26
2323
dist: trusty
2424
# single configuration to test with Lmod 6 and Python 2.7
2525
- python: 2.7

easybuild/tools/options.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,6 @@ def set_up_configuration(args=None, logfile=None, testing=False, silent=False):
13041304
:param testing: enable testing mode
13051305
:param silent: stay silent (no printing)
13061306
"""
1307-
check_python_version()
13081307

13091308
# set up fake 'vsc' Python package, to catch easyblocks/scripts that still import from vsc.* namespace
13101309
# this must be done early on, to catch imports from the vsc namespace in modules included via --include-*
@@ -1371,6 +1370,8 @@ def set_up_configuration(args=None, logfile=None, testing=False, silent=False):
13711370
init(options, config_options_dict)
13721371
init_build_options(build_options=build_options, cmdline_options=options)
13731372

1373+
check_python_version()
1374+
13741375
# move directory containing fake vsc namespace into temporary directory used for this session
13751376
# (to ensure it gets cleaned up properly)
13761377
new_fake_vsc_path = os.path.join(tmpdir, os.path.basename(fake_vsc_path))

easybuild/tools/systemtools.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
from easybuild.base import fancylogger
4545
from easybuild.tools.build_log import EasyBuildError
46+
from easybuild.tools.config import build_option
4647
from easybuild.tools.filetools import is_readable, read_file, which
4748
from easybuild.tools.run import run_cmd
4849

@@ -840,11 +841,17 @@ def check_python_version():
840841
python_ver = '%d.%d' % (python_maj_ver, python_min_ver)
841842
_log.info("Found Python version %s", python_ver)
842843

844+
silence_deprecation_warnings = build_option('silence_deprecation_warnings') or []
845+
843846
if python_maj_ver == 2:
844847
if python_min_ver < 6:
845848
raise EasyBuildError("Python 2.6 or higher is required when using Python 2, found Python %s", python_ver)
846849
elif python_min_ver == 6:
847-
_log.deprecated("Running EasyBuild with Python 2.6 is deprecated", '5.0')
850+
depr_msg = "Running EasyBuild with Python 2.6 is deprecated"
851+
if 'Python26' in silence_deprecation_warnings:
852+
_log.warning(depr_msg)
853+
else:
854+
_log.deprecated(depr_msg, '5.0')
848855
else:
849856
_log.info("Running EasyBuild with Python 2 (version %s)", python_ver)
850857

test/framework/systemtools.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import re
3232
import sys
3333

34-
from test.framework.utilities import EnhancedTestCase, TestLoaderFiltered
34+
from test.framework.utilities import EnhancedTestCase, TestLoaderFiltered, init_config
3535
from unittest import TextTestRunner
3636

3737
import easybuild.tools.systemtools as st
@@ -774,6 +774,8 @@ def test_det_terminal_size(self):
774774
def test_check_python_version(self):
775775
"""Test check_python_version function."""
776776

777+
init_config(build_options={'silence_deprecation_warnings': []})
778+
777779
def mock_python_ver(py_maj_ver, py_min_ver):
778780
"""Helper function to mock a particular Python version."""
779781
st.sys.version_info = (py_maj_ver, py_min_ver) + sys.version_info[2:]

0 commit comments

Comments
 (0)