Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
21979b7
Run pytest suite.
sbrodehl Dec 22, 2020
2b1ef1e
Create pytest.yml
sbrodehl Dec 22, 2020
7bc5647
Remove testing from linter.
sbrodehl Dec 22, 2020
4496f85
remove default keyword for any module names
da-h Dec 7, 2020
e451f5f
[modules] print also submodules
da-h Dec 7, 2020
5336e32
changed offset of relative module paths
da-h Dec 7, 2020
f10c484
tests: added basic import tests
da-h Dec 22, 2020
185b202
tests: added relative import tests
da-h Dec 22, 2020
adfe1ae
remove single dash arguments again (introduced in v1.26)
da-h Dec 7, 2020
92fa189
tests: added argparse tests
da-h Dec 22, 2020
6c7a385
argparse: quickfix for missing argparse support of negative scientifi…
da-h Dec 22, 2020
e311134
bugfix: boolean list defaults did not work
da-h Dec 22, 2020
28551e9
tests: speedtest: deactivated & fixed pylint errors
da-h Dec 28, 2020
1ab019d
.gitignore: added tests/*/miniflask (links to this very miniflask ver…
da-h Dec 28, 2020
b22e72b
import_module: bugfix for case where module exists, but __init__ is i…
da-h Dec 28, 2020
e352d4a
tests: replaced pip install with link to current version
da-h Dec 29, 2020
1148e17
tests: removing deactivated tests from repository
da-h Dec 29, 2020
22c68aa
tests: minor pylint fix
da-h Dec 29, 2020
e63fbfa
.github/workflows/pytest: let pylint use current version & check all …
da-h Dec 29, 2020
55e48a6
tests: fixed missing ignore of sys.argv to all tests
da-h Dec 29, 2020
ef8f991
bugfix: add package_prefix to all modules to ensure multiple instance…
da-h Dec 29, 2020
f6b1306
enabled PosixPath for miniflask.init(module_dirs=...)
da-h Dec 30, 2020
0a85fc1
rename mf.redefine_scope(new_id) -> mf.register_as(new_id)
da-h Dec 29, 2020
b6c10c5
tests: added tests for register_as
da-h Dec 30, 2020
0854fff
bugfix: event[module_id] was wrong if module name changes during regi…
da-h Dec 30, 2020
4d8c5ef
rework register_as and the internal use of the repository name
da-h Dec 30, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/linting-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
python -m pip install flake8 pylint pytest
python -m pip install flake8 pylint
# install deps for pylint
python -m pip install colored
# build and install the package itself
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Testing

on: [push]

jobs:
Pytest:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Set up Python 3.x
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
python -m pip install flake8 pylint pytest
# install deps for pylint
python -m pip install colored
- name: Syntax Check of Tests
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 tests --count --select=E9,F63,F7,F82 --show-source --statistics
- name: Static Analysis of Tests (Modules)
run: |
flake8 tests --count --ignore E501 --statistics
PYTHONPATH=$(pwd)/src find tests -type d -exec test -e '{}'/.module \; -exec pylint -d W0511 -d C0114 -d C0116 -d C0115 -d C0301 -d C0103 -d R0913 -d R0914 -d R0902 -d R0912 -d R0801 -d W0212 -d W0223 -d E1101 -d W0221 -d E1102 '{}' +
PYTHONPATH=$(pwd)/src find tests -type d -exec test -e '{}'/.module \; -exec pylint --exit-zero '{}' +
- name: Pytest
run: pytest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
tests_deact
.idea
# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ repos:
- id: check-yaml
- id: check-added-large-files
- id: flake8
args: [--count,--ignore,E501,--statistics,--exclude,.git,__pycache__]
args: [--count,--ignore,E501,--statistics,--exclude,.git]
- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
entry: bash -c "PYTHONPATH=$(pwd)/src find tests -type d -exec test -e '{}'/.module \; -exec pylint -d W0511 -d C0114 -d C0116 -d C0115 -d C0301 -d C0103 -d R0913 -d R0914 -d R0902 -d R0912 -d R0801 -d W0212 -d W0223 -d E1101 -d W0221 -d E1102 '{}' +"
language: system
types: [python]
args: [ -d W0511 , -d C0114 , -d C0116 , -d C0115 , -d C0301 , -d C0103 , -d R0913 , -d R0914 , -d R0902 , -d R0912 , -d R0801 , -d W0212 , -d W0223 , -d E1101 , -d W0221 , -d E1102, -d E0611 ]
args: [ ]
148 changes: 80 additions & 68 deletions src/miniflask/miniflask.py

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions src/miniflask/modules/modules/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
def showModules(state, event):
event._mf.showModules(with_event=state.all["events"])
print()
print(event._mf.showModules(with_event=state.all["events"]))


def register(mf):
Expand Down
5 changes: 1 addition & 4 deletions src/miniflask/modules/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ def listsettings(state, asciicodes=True):
if len(k) > 1:
k_hidden = [" " * len(ki) if ki == ki2 and asciicodes else ki for ki, ki2 in zip_longest(k, last_k) if ki is not None]
last_k = k
if k_hidden[-2] == "default":
k_hidden[-3] = color_name(k_hidden[-3])
else:
k_hidden[-2] = color_name(k_hidden[-2])
k_hidden[-2] = color_name(k_hidden[-2])
k_hidden[-1] = color_module(k_hidden[-1])
else:
k_hidden = k
Expand Down
2 changes: 1 addition & 1 deletion src/miniflask/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def getModulesAvail(module_dirs, f=None):
f = {}
for base_module_name, directory in module_dirs.items():
base_module_name = base_module_name.replace(".", "_")
# basename_dir = path.basename(directory)
directory = str(directory) # in case directory is given as PosixPath etc.
for (dirpath, dirnames, filenames) in walk(directory):
local_import_name = dirpath[len(directory) + 1:].replace(path.sep, ".")
module_name_id = base_module_name + "." + local_import_name
Expand Down
1 change: 1 addition & 0 deletions tests/enums/miniflask
1 change: 1 addition & 0 deletions tests/exception_event/miniflask
1 change: 1 addition & 0 deletions tests/exception_register/miniflask
1 change: 1 addition & 0 deletions tests/features/miniflask
1 change: 1 addition & 0 deletions tests/outervar/miniflask
7 changes: 0 additions & 7 deletions tests/speedtest/modules/modulenomfargs/__init__.py

This file was deleted.

7 changes: 0 additions & 7 deletions tests/speedtest/modules/modulenonunique/__init__.py

This file was deleted.

13 changes: 0 additions & 13 deletions tests/speedtest/modules/moduleunique/__init__.py

This file was deleted.

24 changes: 0 additions & 24 deletions tests/speedtest/test_mf_class.py

This file was deleted.

17 changes: 0 additions & 17 deletions tests/speedtest/test_mf_event.py

This file was deleted.

17 changes: 0 additions & 17 deletions tests/speedtest/test_mf_event_nomfargs.py

This file was deleted.

17 changes: 0 additions & 17 deletions tests/speedtest/test_mf_event_nonunique.py

This file was deleted.

21 changes: 0 additions & 21 deletions tests/speedtest/test_mf_python.py

This file was deleted.

17 changes: 0 additions & 17 deletions tests/speedtest/test_mf_state.py

This file was deleted.

17 changes: 0 additions & 17 deletions tests/speedtest/test_mf_state_fuzzy.py

This file was deleted.

8 changes: 0 additions & 8 deletions tests/speedtest/test_python.py

This file was deleted.

50 changes: 50 additions & 0 deletions tests/test_argparse/modules/module1/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from enum import Enum


class SIZE(Enum):
SMALL = 0
MEDIUM = 1
LARGE = 2


def print_all(state):
print("int1:", state["int1"])
print("int2:", state["int2"])
print("float1:", state["float1"])
print("float2:", state["float2"])
print("float3:", state["float3"])
print("float4:", state["float4"])
print("float5:", state["float5"])
print("float6:", state["float6"])
print("bool1:", state["bool1"])
print("bool2:", state["bool2"])
print("enum1:", state["enum1"])
print("str1:", state["str1"])
print("str2:", state["str2"])
print("str3:", state["str3"])


def print_bool(state):
print("bool1:", state["bool1"])
print("bool2:", state["bool2"])


def register(mf):
mf.register_defaults({
"int1": 42,
"int2": -42,
"float1": 2.345,
"float2": -2.345,
"float3": 0.0,
"float4": -0.0,
"float5": 1e7,
"float6": -1e7,
"bool1": True,
"bool2": False,
"enum1": SIZE.MEDIUM,
"str1": "",
"str2": "abcd1234",
"str3": "αβγδ∀⇐Γ∂",
})
mf.register_event('print_all', print_all)
mf.register_event('print_bool', print_bool)
Loading