Skip to content

Commit 6263f0e

Browse files
authored
Switch to tox for tests (#73)
1 parent 17d8586 commit 6263f0e

File tree

6 files changed

+18
-71
lines changed

6 files changed

+18
-71
lines changed

.github/workflows/python-app.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@ jobs:
2323
- name: Install dependencies
2424
run: |
2525
python -m pip install --upgrade pip
26-
pip install flake8==3.8.4 pytest
27-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
28-
- name: Lint with flake8
26+
pip install tox
27+
- name: Lint and test
2928
run: |
30-
python setup.py lint
31-
- name: Test with pytest
32-
run: |
33-
python setup.py test
29+
tox

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
/venv
1010
build/
1111
.vscode/settings.json
12+
.tox/

README.rst

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,4 @@ They are the same as listed above and take the same arguments.
186186
Development
187187
===========
188188

189-
To run tests:
190-
191-
``python setup.py test``
192-
193-
To lint:
194-
195-
``python setup.py lint``
189+
To run tests and the linter run ``pip install tox`` once, then ``tox``.

setup.cfg

Lines changed: 0 additions & 2 deletions
This file was deleted.

setup.py

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import codecs
33
import os
44
from setuptools import setup, find_packages
5-
from setuptools.command.test import test as TestCommand, Command
65

76

87
read = lambda filepath: codecs.open(filepath, 'r', 'utf-8').read()
@@ -13,49 +12,7 @@
1312
'__version__': '0.11.2',
1413
}
1514

16-
17-
class PyTest(TestCommand):
18-
def finalize_options(self):
19-
TestCommand.finalize_options(self)
20-
self.test_args = ['tests', '-s']
21-
self.test_suite = True
22-
23-
def run_tests(self):
24-
import pytest
25-
errno = pytest.main(self.test_args)
26-
raise SystemExit(errno)
27-
28-
29-
class LintCommand(Command):
30-
"""
31-
A copy of flake8's Flake8Command
32-
33-
"""
34-
description = "Run flake8 on modules registered in setuptools"
35-
user_options = []
36-
37-
def initialize_options(self):
38-
pass
39-
40-
def finalize_options(self):
41-
pass
42-
43-
def distribution_files(self):
44-
if self.distribution.packages:
45-
for package in self.distribution.packages:
46-
yield package.replace(".", os.path.sep)
47-
48-
if self.distribution.py_modules:
49-
for filename in self.distribution.py_modules:
50-
yield "%s.py" % filename
51-
52-
def run(self):
53-
from flake8.api.legacy import get_style_guide
54-
flake8_style = get_style_guide(config_file='setup.cfg')
55-
paths = self.distribution_files()
56-
report = flake8_style.check_files(paths)
57-
raise SystemExit(report.total_errors > 0)
58-
15+
read = lambda filepath: codecs.open(filepath, 'r', 'utf-8').read()
5916

6017
setup(
6118
name='markdownify',
@@ -69,14 +26,9 @@ def run(self):
6926
packages=find_packages(),
7027
zip_safe=False,
7128
include_package_data=True,
72-
setup_requires=[
73-
'flake8>=3.8,<5',
74-
],
75-
tests_require=[
76-
'pytest>=6.2,<7',
77-
],
7829
install_requires=[
79-
'beautifulsoup4>=4.9,<5', 'six>=1.15,<2'
30+
'beautifulsoup4>=4.9,<5',
31+
'six>=1.15,<2',
8032
],
8133
classifiers=[
8234
'Environment :: Web Environment',
@@ -92,10 +44,6 @@ def run(self):
9244
'Programming Language :: Python :: 3.8',
9345
'Topic :: Utilities'
9446
],
95-
cmdclass={
96-
'test': PyTest,
97-
'lint': LintCommand,
98-
},
9947
entry_points={
10048
'console_scripts': [
10149
'markdownify = markdownify.main:main'

tox.ini

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[tox]
2+
envlist = py38
3+
4+
[testenv]
5+
deps =
6+
flake8
7+
pytest
8+
commands =
9+
flake8 --ignore=E501,W503 markdownify tests
10+
pytest

0 commit comments

Comments
 (0)