Skip to content

Commit

Permalink
scripts/ tests/: don't run pip install within individual tests.
Browse files Browse the repository at this point in the history
Instead have added missing flake8 to scripts/gh_release.py:test_packages, so
all required packages will already be available, e.g. when tests are run by
`scripts/test.py`.

This addresses #2950 "Shelling out to pip during tests is problematic".
  • Loading branch information
julian-smith-artifex-com committed Jan 5, 2024
1 parent e47f480 commit 4f8e5be
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 7 deletions.
2 changes: 1 addition & 1 deletion scripts/gh_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ def platform_tag():
# If this has changed, need to update
# .github/workflows/*.yml.
#
test_packages = 'pytest fontTools psutil pymupdf-fonts'
test_packages = 'pytest fontTools psutil pymupdf-fonts flake8'
if platform.system() == 'Windows' and cpu_bits() == 32:
# No pillow wheel available, and doesn't build easily.
pass
Expand Down
5 changes: 0 additions & 5 deletions tests/test_flake8.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ def test_flake8():
if not hasattr(fitz, 'mupdf'):
print(f'Not running flake8 with classic implementation.')
return
if sys.prefix == sys.base_prefix:
# We install flake8, which we only want to do if we are in a venv.
print(f'Not running flake8 because we are not in a venv.')
return
ignores = (
'E123', # closing bracket does not match indentation of opening bracket's line
'E124', # closing bracket does not match visual indentation
Expand Down Expand Up @@ -53,6 +49,5 @@ def test_flake8():
def run(command):
print(f'test_flake8(): Running: {command}')
subprocess.run(command, shell=1, check=1)
run(f'pip install flake8')
run(f'flake8 --ignore={ignores} --statistics {root}/src/__init__.py {root}/src/utils.py {root}/src/table.py')
print(f'test_flake8(): flake8 succeeded.')
1 change: 0 additions & 1 deletion tests/test_font.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def test_2608():

def test_fontarchive():
import subprocess
subprocess.run('pip install pymupdf-fonts', shell=1, check=1)
arch = fitz.Archive()
css = fitz.css_for_pymupdf_font("notos", archive=arch, name="sans-serif")
print(css)
Expand Down

0 comments on commit 4f8e5be

Please sign in to comment.