Repository: bokeh/bokeh

Issue:
Configure codebase tests with `git ls-files`
Otherwise I get lot of unrelated errors in temporary files.



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -59,23 +59,22 @@
 an sdist. They will be ignored, and warning printed.
 
 '''
+import sys
 from os.path import join
 from shutil import copy
-import sys
-
-# immediately bail on unsupported Python versions
-if sys.version_info[:2] < (3, 6):
-    raise RuntimeError("Bokeh requires python >= 3.6")
 
 from setuptools import find_packages, setup
 
-from _setup_support import (
-    build_or_install_bokehjs, check_building_sdist, conda_rendering,
-    fixup_for_packaged, get_cmdclass, get_package_data, get_version,
-    install_js, package_files, package_path, ROOT, SERVER, show_bokehjs,
-    show_help
+from _setup_support import ( # isort:skip
+    ROOT, SERVER, build_or_install_bokehjs, check_building_sdist,
+    conda_rendering, fixup_for_packaged, get_cmdclass, get_package_data,
+    get_version, install_js, package_files, package_path, show_bokehjs, show_help,
 )
 
+# immediately bail on unsupported Python versions
+if sys.version_info[:2] < (3, 6):
+    raise RuntimeError("Bokeh requires python >= 3.6")
+
 # immediately handle lightweight "python setup.py --install-js"
 if len(sys.argv) == 2 and sys.argv[-1] == '--install-js':
     install_js()


Test patch:
diff --git a/tests/codebase/__init__.py b/tests/codebase/__init__.py
--- a/tests/codebase/__init__.py
+++ b/tests/codebase/__init__.py
@@ -8,5 +8,11 @@
 
 # Standard library imports
 from os.path import abspath, join, pardir, split
+from subprocess import run
+from typing import List
 
 TOP_PATH = abspath(join(split(__file__)[0], pardir, pardir))
+
+def ls_files(*patterns: str) -> List[str]:
+    proc = run(["git", "ls-files", "--", *patterns], capture_output=True)
+    return proc.stdout.decode("utf-8").split("\n")
diff --git a/tests/codebase/test_flake8.py b/tests/codebase/test_flake8.py
--- a/tests/codebase/test_flake8.py
+++ b/tests/codebase/test_flake8.py
@@ -17,10 +17,10 @@
 
 # Standard library imports
 from os import chdir
-from subprocess import PIPE, Popen
+from subprocess import run
 
 # Bokeh imports
-from . import TOP_PATH
+from . import TOP_PATH, ls_files
 
 #-----------------------------------------------------------------------------
 # Tests
@@ -31,9 +31,8 @@ def test_flake8() -> None:
 
     '''
     chdir(TOP_PATH)
-    proc = Popen(["flake8"], stdout=PIPE, stderr=PIPE)
-    out, _ = proc.communicate()
-    assert proc.returncode == 0, "Flake8 issues:\n%s" % out.decode("utf-8")
+    proc = run(["flake8", *ls_files("*.py")], capture_output=True)
+    assert proc.returncode == 0, f"Flake8 issues:\n{proc.stdout.decode('utf-8')}"
 
 #-----------------------------------------------------------------------------
 # Support
diff --git a/tests/codebase/test_isort.py b/tests/codebase/test_isort.py
--- a/tests/codebase/test_isort.py
+++ b/tests/codebase/test_isort.py
@@ -17,10 +17,10 @@
 
 # Standard library imports
 from os import chdir
-from subprocess import PIPE, Popen
+from subprocess import run
 
 # Bokeh imports
-from . import TOP_PATH
+from . import TOP_PATH, ls_files
 
 #-----------------------------------------------------------------------------
 # Tests
@@ -31,9 +31,8 @@ def test_isort() -> None:
 
     '''
     chdir(TOP_PATH)
-    proc = Popen(["isort", "-df", "-rc", "-c", "."], stdout=PIPE, stderr=PIPE)
-    out, _ = proc.communicate()
-    assert proc.returncode == 0, "isort issues:\n%s" % out.decode("utf-8")
+    proc = run(["isort", "-df", "-rc", "-c", *ls_files("*.py")], capture_output=True)
+    assert proc.returncode == 0, f"isort issues:\n{proc.stdout.decode('utf-8')}"
 
 #-----------------------------------------------------------------------------
 # Support