From 10fddad26b46fd7254198c2480b3ea21b32d5944 Mon Sep 17 00:00:00 2001 From: JensDiemer Date: Wed, 19 Feb 2020 10:14:56 +0100 Subject: merge code: use existing test code from poetry-publish --- creole/tests/test_project_setup.py | 62 ++++++++++++-------------------------- 1 file changed, 19 insertions(+), 43 deletions(-) diff --git a/creole/tests/test_project_setup.py b/creole/tests/test_project_setup.py index 4a78c70..4d100a3 100644 --- a/creole/tests/test_project_setup.py +++ b/creole/tests/test_project_setup.py @@ -2,58 +2,34 @@ :copyleft: 2020 by python-creole team, see AUTHORS for more details. :license: GNU GPL v3 or above, see LICENSE for more details. """ -import os -import shutil -import subprocess -from pathlib import Path + +from poetry_publish.tests.test_project_setup import test_assert_rst_readme as assert_rst_readme +from poetry_publish.tests.test_project_setup import test_poetry_check as assert_poetry_check +from poetry_publish.tests.test_project_setup import test_version as assert_version from creole import __version__ -from creole.setup_utils import assert_rst_readme from creole.tests.constants import CREOLE_PACKAGE_ROOT -def assert_file_contains_string(file_path, string): - with file_path.open('r') as f: - for line in f: - if string in line: - return - raise AssertionError(f'File {file_path} does not contain {string!r} !') - - def test_version(): - if 'dev' not in __version__ and 'rc' not in __version__: - version_string = f'v{__version__}' - - assert_file_contains_string( - file_path=Path(CREOLE_PACKAGE_ROOT, 'README.creole'), - string=version_string - ) - - assert_file_contains_string( - file_path=Path(CREOLE_PACKAGE_ROOT, 'README.rst'), - string=version_string - ) - - assert_file_contains_string( - file_path=Path(CREOLE_PACKAGE_ROOT, 'pyproject.toml'), - string=f'version = "{__version__}"' - ) + """ + Check if current version exists in README + Check if current version is in pyproject.toml + """ + assert_version(package_root=CREOLE_PACKAGE_ROOT, version=__version__) def test_assert_rst_readme(): - if 'dev' not in __version__ and 'rc' not in __version__: - assert_rst_readme(package_root=CREOLE_PACKAGE_ROOT) + """ + Check if own README.rst is up-to-date with README.creole + """ + assert_rst_readme( + package_root=CREOLE_PACKAGE_ROOT, version=__version__, filename='README.creole' + ) def test_poetry_check(): - poerty_bin = shutil.which('poetry') - - output = subprocess.check_output( - [poerty_bin, 'check'], - universal_newlines=True, - env=os.environ, - stderr=subprocess.STDOUT, - cwd=str(CREOLE_PACKAGE_ROOT), - ) - print(output) - assert output == 'All set!\n' + """ + Test 'poetry check' output. + """ + assert_poetry_check(package_root=CREOLE_PACKAGE_ROOT) -- cgit v1.2.1