Refactored the code for testing and packaging

This commit is contained in:
Maximilien Rigaut 2022-01-25 02:41:03 +01:00
parent 2c0ca29ed4
commit 4cf96638b8
22 changed files with 136 additions and 16 deletions

View File

@ -5,9 +5,9 @@ name: Python application
on:
push:
branches: [ main ]
branches: [ main, test ]
pull_request:
branches: [ main ]
branches: [ main, test ]
schedule:
- cron: '0 6 * * *'
@ -16,8 +16,6 @@ jobs:
build:
runs-on: ubuntu-latest
env:
FIB_INPUT: 10
steps:
- uses: actions/checkout@v2
@ -29,13 +27,14 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install -r requirements_dev.txt
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
# - name: Test with pytest
# run: |
# pytest fibtest.py
- name: Test with pytest
run: |
pip install .
pytest .

23
pyproject.toml Normal file
View File

@ -0,0 +1,23 @@
[build-system]
requires = ["setuptools>=42.0", "wheel"]
build-backend = "setuptools.build_meta"
[tool.pytest.ini_options]
addopts = "--cov=bootstraparse"
testpaths = [
"tests",
]
[tool.mypy]
mypy_path = "src"
check_untyped_defs = true
disallow_any_generics = true
ignore_missing_imports = true
no_implicit_optional = true
show_error_codes = true
strict_equality = true
warn_redundant_casts = true
warn_return_any = true
warn_unreachable = true
warn_unused_configs = true
no_implicit_reexport = true

View File

@ -1 +1,2 @@
pyyaml==6.0
pyyaml==6.0
rich~=11.0.0

7
requirements_dev.txt Normal file
View File

@ -0,0 +1,7 @@
flake8==4.0.1
tox==3.24.3
pytest==6.2.5
pytest-cov==2.12.1
mypy===0.910
pyyaml==6.0
rich~=11.0.0

45
setup.cfg Normal file
View File

@ -0,0 +1,45 @@
[metadata]
name = bootstraparse
description = A custom markdown parser for Bootstrap & Python
author = Vkyfox
license = Mozilla Public License Version 2.0
license_file = LICENSE
platforms = unix, linux, osx, cygwin, win32
classifiers =
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
[options]
packages =
bootstraparse
bootstraparse.modules
install_requires =
pyyaml>=6.0
python_requires = >=3.6
package_dir =
=src
zip_safe = no
[options.packages.find]
where =
= src
= src/bootstraparse
[options.extras_require]
testing =
flake8>=4.0.1
tox>=3.24.3
pytest>=6.2.5
pytest-cov>=2.12.1
mypy>==0.910
pyyaml>=6.0
[options.package_data]
slapping = py.typed
[flake8]
max-line-length = 160

View File

@ -1 +1,4 @@
# Main program, use this to start parsing
def totest():
print("This is a test")

View File

@ -32,4 +32,4 @@ class GlobalConfig(ConfigLoader):
super().__init__(configfile)
conf = ConfigLoader("./example_userfiles/config/aliases.yml")
# conf = ConfigLoader("./example_userfiles/config/aliases.yml")

View File

@ -1,6 +1,7 @@
# Module sequencing the successive actions necessary for website building
import modules.config as config
import bootstraparse.modules.config as config
def create_website():

View File

@ -0,0 +1,10 @@
import modules.sitecreator as sitecreator
from rich import print, pretty, inspect
pretty.install()
conf = sitecreator.create_config()
print("[red]test",conf)
inspect(conf)

View File

@ -1,5 +0,0 @@
import modules.sitecreator as sitecreator
conf = sitecreator.create_config()
print(conf)

7
tests/test_bparse.py Normal file
View File

@ -0,0 +1,7 @@
# Test the base parser
from bootstraparse import bparse
def test_totest():
assert bparse.totest() is None

29
tox.ini Normal file
View File

@ -0,0 +1,29 @@
[tox]
minversion = 3.8.0
envlist = py37, py38, py39, flake8, mypy
isolated_build = true
[gh-actions]
python =
3.7: py36, mypy, flake8
3.8: py38
3.9: py39
[testenv]
setenv =
PYTHONPATH = {toxinidir}
deps =
-r{toxinidir}/requirements_dev.txt
commands =
pytest --basetemp={envtmpdir}
[testenv:flake8]
basepython = python3.7
deps = flake8
commands = flake8 src tests
[testenv:mypy]
basepython = python3.7
deps =
-r{toxinidir}/requirements_dev.txt
commands = mypy src