Skip to content

Commit

Permalink
Switch to tox for tests (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVonB authored Aug 28, 2022
1 parent 17d8586 commit 6263f0e
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 71 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8==3.8.4 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
pip install tox
- name: Lint and test
run: |
python setup.py lint
- name: Test with pytest
run: |
python setup.py test
tox
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
/venv
build/
.vscode/settings.json
.tox/
8 changes: 1 addition & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``.
2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

58 changes: 3 additions & 55 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -13,49 +12,7 @@
'__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',
Expand All @@ -69,14 +26,9 @@ def run(self):
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',
Expand All @@ -92,10 +44,6 @@ def run(self):
'Programming Language :: Python :: 3.8',
'Topic :: Utilities'
],
cmdclass={
'test': PyTest,
'lint': LintCommand,
},
entry_points={
'console_scripts': [
'markdownify = markdownify.main:main'
Expand Down
10 changes: 10 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[tox]
envlist = py38

[testenv]
deps =
flake8
pytest
commands =
flake8 --ignore=E501,W503 markdownify tests
pytest

0 comments on commit 6263f0e

Please sign in to comment.