diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 000c0b2..033cc20 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -23,11 +23,8 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flake8==3.8.4 pytest + pip install flake8==3.8.4 pytest tox if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 + - name: Lint and test run: | - python setup.py lint - - name: Test with pytest - run: | - python setup.py test + tox diff --git a/.gitignore b/.gitignore index 100084d..18d16bf 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ /venv build/ .vscode/settings.json +.tox/ diff --git a/README.rst b/README.rst index beb7f8b..7cf2c1d 100644 --- a/README.rst +++ b/README.rst @@ -186,10 +186,4 @@ They are the same as listed above and take the same arguments. Development =========== -To run tests: - -``python setup.py test`` - -To lint: - -``python setup.py lint`` +To run tests and the linter run ``pip install tox`` once, then ``tox``. diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 32e2565..0000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[flake8] -ignore = E501 W503 diff --git a/setup.py b/setup.py index 171c45d..0e772ef 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,6 @@ import codecs import os from setuptools import setup, find_packages -from setuptools.command.test import test as TestCommand, Command read = lambda filepath: codecs.open(filepath, 'r', 'utf-8').read() @@ -13,49 +12,7 @@ pkgmeta = { '__version__': '0.11.2', } - -class PyTest(TestCommand): - def finalize_options(self): - TestCommand.finalize_options(self) - self.test_args = ['tests', '-s'] - self.test_suite = True - - def run_tests(self): - import pytest - errno = pytest.main(self.test_args) - raise SystemExit(errno) - - -class LintCommand(Command): - """ - A copy of flake8's Flake8Command - - """ - description = "Run flake8 on modules registered in setuptools" - user_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def distribution_files(self): - if self.distribution.packages: - for package in self.distribution.packages: - yield package.replace(".", os.path.sep) - - if self.distribution.py_modules: - for filename in self.distribution.py_modules: - yield "%s.py" % filename - - def run(self): - from flake8.api.legacy import get_style_guide - flake8_style = get_style_guide(config_file='setup.cfg') - paths = self.distribution_files() - report = flake8_style.check_files(paths) - raise SystemExit(report.total_errors > 0) - +read = lambda filepath: codecs.open(filepath, 'r', 'utf-8').read() setup( name='markdownify', @@ -69,14 +26,9 @@ setup( packages=find_packages(), zip_safe=False, include_package_data=True, - setup_requires=[ - 'flake8>=3.8,<5', - ], - tests_require=[ - 'pytest>=6.2,<7', - ], install_requires=[ - 'beautifulsoup4>=4.9,<5', 'six>=1.15,<2' + 'beautifulsoup4>=4.9,<5', + 'six>=1.15,<2', ], classifiers=[ 'Environment :: Web Environment', @@ -92,10 +44,6 @@ setup( 'Programming Language :: Python :: 3.8', 'Topic :: Utilities' ], - cmdclass={ - 'test': PyTest, - 'lint': LintCommand, - }, entry_points={ 'console_scripts': [ 'markdownify = markdownify.main:main' diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..1e137fb --- /dev/null +++ b/tox.ini @@ -0,0 +1,10 @@ +[tox] +envlist = py38 + +[testenv] +deps = + flake8 + pytest +commands = + flake8 --ignore=E501,W503 markdownify tests + pytest