From 827add69de409d34fe98d85be729226dbfc5dca4 Mon Sep 17 00:00:00 2001 From: bwoodsend Date: Sat, 3 Oct 2020 14:58:29 +0100 Subject: [PATCH] Tests: Update sysconfig test to not depend on obsolete data files. The pyconfig.h and makefile are no longer used. The correct way to use sysconfig is through `sysconfig.get_config_vars()` which is now tested instead of checking the files are present. --- .../functional/scripts/pyi_python_makefile.py | 36 ------------------- tests/functional/test_basic.py | 17 +++++++-- 2 files changed, 14 insertions(+), 39 deletions(-) delete mode 100644 tests/functional/scripts/pyi_python_makefile.py diff --git a/tests/functional/scripts/pyi_python_makefile.py b/tests/functional/scripts/pyi_python_makefile.py deleted file mode 100644 index 47a9edacf02..00000000000 --- a/tests/functional/scripts/pyi_python_makefile.py +++ /dev/null @@ -1,36 +0,0 @@ -#----------------------------------------------------------------------------- -# Copyright (c) 2005-2020, PyInstaller Development Team. -# -# Distributed under the terms of the GNU General Public License (version 2 -# or later) with exception for distributing the bootloader. -# -# The full license is in the file COPYING.txt, distributed with this software. -# -# SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception) -#----------------------------------------------------------------------------- - - -# distutils module requires Makefile and pyconfig.h files from Python -# installation. - - -import os -import sys -import sysconfig - - -config_h = sysconfig.get_config_h_filename() -print(('pyconfig.h: ' + config_h)) -files = [config_h] - - -# On Windows Makefile does not exist. -if not sys.platform.startswith('win'): - makefile = sysconfig.get_makefile_filename() - print(('Makefile: ' + makefile)) - files.append(makefile) - - -for f in files: - if not os.path.exists(f): - raise SystemExit('File does not exist: %s' % f) diff --git a/tests/functional/test_basic.py b/tests/functional/test_basic.py index df9cdaef3c5..b5b35a8eafd 100644 --- a/tests/functional/test_basic.py +++ b/tests/functional/test_basic.py @@ -332,9 +332,20 @@ def MyEXE(*args, **kwargs): _, err = capsys.readouterr() assert "'import warnings' failed" not in err -@skipif_win -def test_python_makefile(pyi_builder): - pyi_builder.test_script('pyi_python_makefile.py') + +@pytest.mark.parametrize("distutils", ["", "from distutils "]) +def test_python_makefile(pyi_builder, distutils): + """Tests hooks for ``sysconfig`` and its near-duplicate + ``distutils.sysconfig``. Should raise a distutils error if it needed the + ``pyconfig.h`` and ``makefile`` and didn't get them. Or an import error if + we failed to include the special extension module that replaced those + files in more modern Python versions. + """ + pyi_builder.test_source(""" + {}import sysconfig + from pprint import pprint + pprint(sysconfig.get_config_vars()) + """.format(distutils)) def test_set_icon(pyi_builder, data_dir):