From 38bc57874420698158bf1ea6261f6efea61379a7 Mon Sep 17 00:00:00 2001 From: Jakub Roztocil Date: Wed, 4 Dec 2019 18:09:51 +0100 Subject: [PATCH] Fix tests --- Makefile | 8 ++++---- tests/test_docs.py | 19 ++++++++++++++++--- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index a141b57f..757924b8 100644 --- a/Makefile +++ b/Makefile @@ -93,7 +93,7 @@ test-dist: test-sdist test-bdist-wheel test-tox: uninstall-httpie install @echo $(H1)Running tests on all Pythons via Tox$(H1END) - tox + $(VENV_BIN)/tox @echo @@ -139,8 +139,8 @@ publish-no-test: @echo $(H1)Testing wheel build an installation$(H1END) @echo "$(VERSION)" @echo "$(VERSION)" | grep -q "dev" && echo '!!!Not publishing dev version!!!' && exit 1 || echo ok - python setup.py sdist bdist_wheel - twine upload dist/* + $(VENV_PYTHON) setup.py sdist bdist_wheel + $(VENV_BIN)/twine upload dist/* @echo @@ -154,7 +154,7 @@ uninstall-httpie: - $(VENV_PIP) uninstall --yes httpie &2>/dev/null @echo "Verifying…" - cd .. && ! python -m httpie --version &2>/dev/null + cd .. && ! $(VENV_PYTHON) -m httpie --version &2>/dev/null @echo "Done" @echo diff --git a/tests/test_docs.py b/tests/test_docs.py index f850c588..7a418228 100644 --- a/tests/test_docs.py +++ b/tests/test_docs.py @@ -1,6 +1,7 @@ import os import subprocess from glob import glob +from pathlib import Path import pytest @@ -38,12 +39,24 @@ filenames = list(sorted(rst_filenames())) assert filenames -@pytest.mark.skipif(not has_docutils(), reason='docutils not installed') +# HACK: hardcoded paths, venv should be irrelevant, etc. +# TODO: replaces the process with Python code +VENV_BIN = Path(__file__).parent.parent / 'venv/bin' +VENV_PYTHON = VENV_BIN / 'python' +VENV_RST2PSEUDOXML = VENV_BIN / 'rst2pseudoxml.py' + + +@pytest.mark.skipif(not os.path.exists(VENV_RST2PSEUDOXML), reason='docutils not installed') @pytest.mark.parametrize('filename', filenames) def test_rst_file_syntax(filename): - print(filename) p = subprocess.Popen( - ['rst2pseudoxml.py', '--report=1', '--exit-status=1', filename], + [ + VENV_PYTHON, + VENV_RST2PSEUDOXML, + '--report=1', + '--exit-status=1', + filename, + ], stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True,