Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
43 changes: 24 additions & 19 deletions .run/commands/pylint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,35 @@
# We generate relative paths in the output to make integration with Pycharm work better

command_pylint() {
local OPTIND OPTARG option tests template

echo "Running pylint checks..."

tests=""
template="{path}:{line}:{column} - {C} - ({symbol}) - {msg}"

if [ -f "tests/__init__.py" ]; then
local OPTIND OPTARG option tests template

tests="tests"
template="{path}:{line}:{column} - {C} - ({symbol}) - {msg}"

while getopts "t" option; do
case $option in
t)
tests="" # -t means to ignore the tests
;;
?)
echo "invalid option -$OPTARG"
exit 1
;;
esac
done

shift $((OPTIND -1)) # pop off the options consumed by getopts
tests="tests"
elif [ -f "src/tests/__init__.py" ]; then
tests="src/tests"
else
tests=""
fi

while getopts "t" option; do
case $option in
t)
echo "Tests will be ignored"
tests="" # -t means to ignore the tests
;;
?)
echo "invalid option -$OPTARG"
exit 1
;;
esac
done

shift $((OPTIND -1)) # pop off the options consumed by getopts

poetry_run pylint --msg-template="$template" -j 0 "$@" $(ls -d src/*) $tests
echo "done"
}
15 changes: 12 additions & 3 deletions .run/commands/pytest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@
# Run the pytest unit tests, optionally with coverage

command_pytest() {
local OPTIND OPTARG option coverage html color
local OPTIND OPTARG option tests coverage html color

if [ -f "tests/__init__.py" ]; then
tests="tests"
elif [ -f "src/tests/__init__.py" ]; then
tests="src/tests"
else
echo "No tests found"
exit 0
fi

coverage="no"
html="no"
Expand Down Expand Up @@ -30,15 +39,15 @@ command_pytest() {
fi

if [ $coverage == "yes" ]; then
poetry_run coverage run -m pytest --testdox --force-testdox $color tests
poetry_run coverage run -m pytest --testdox --force-testdox $color $tests
poetry_run coverage report
poetry_run coverage lcov -o .coverage.lcov
if [ $html == "yes" ]; then
poetry_run coverage html -d .htmlcov
run_command openfile .htmlcov/index.html
fi
else
poetry_run pytest --testdox --force-testdox $color tests
poetry_run pytest --testdox --force-testdox $color $tests
fi
}

6 changes: 2 additions & 4 deletions .run/tasks/test.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# vim: set ft=bash sw=3 ts=3 expandtab:

help_test() {
if [ -f "tests/__init__.py" ]; then
if [ -f "tests/__init__.py" ] || [ -f "src/tests/__init__.py" ]; then
echo "- run test: Run the unit tests"
echo "- run test -c: Run the unit tests with coverage"
echo "- run test -ch: Run the unit tests with coverage and open the HTML report"
fi
}

task_test() {
if [ -f "tests/__init__.py" ]; then
run_command pytest "$@"
fi
run_command pytest "$@"
}

22 changes: 11 additions & 11 deletions .tabignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Changelog
docs/Makefile
docs/make.bat
tests/fixtures/test_uci/real/dhcp
tests/fixtures/test_uci/real/dropbear
tests/fixtures/test_uci/real/firewall
tests/fixtures/test_uci/real/luci
tests/fixtures/test_uci/real/network
tests/fixtures/test_uci/real/p910nd
tests/fixtures/test_uci/real/rpcd
tests/fixtures/test_uci/real/system
tests/fixtures/test_uci/real/ucitrack
tests/fixtures/test_uci/real/uhttpd
tests/fixtures/test_uci/real/wireless
src/tests/uciparse/fixtures/test_uci/real/dhcp
src/tests/uciparse/fixtures/test_uci/real/dropbear
src/tests/uciparse/fixtures/test_uci/real/firewall
src/tests/uciparse/fixtures/test_uci/real/luci
src/tests/uciparse/fixtures/test_uci/real/network
src/tests/uciparse/fixtures/test_uci/real/p910nd
src/tests/uciparse/fixtures/test_uci/real/rpcd
src/tests/uciparse/fixtures/test_uci/real/system
src/tests/uciparse/fixtures/test_uci/real/ucitrack
src/tests/uciparse/fixtures/test_uci/real/uhttpd
src/tests/uciparse/fixtures/test_uci/real/wireless
1 change: 1 addition & 0 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Version 0.1.27 unreleased
* Add Sphinx configuration path to .readthedocs.yml.
* Adjust GHA build process to allow builds for stacked PRs.
* Add a new `run clean` target to clean up generated data.
* Move unit tests from `tests` into `src/tests/uciparse`.
* Update the jinja2 transitive dependency to address CVE-2025-27516.
* Update the requests transitive dependency to address CVE-2024-47081.
* Update the urllib3 transitive dependency to address CVE-2025-50181.
Expand Down
6 changes: 3 additions & 3 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ environment.
### Project Structure

Go to the PyCharm settings and find the `uci-parse` project. Under
**Project Structure**, mark both `src` and `tests` as source folders. In
the **Exclude Files** box, enter the following:
**Project Structure**, mark `src` as a source folder and `tests` as a test
folder. In the **Exclude Files** box, enter the following:

```
LICENSE;NOTICE;PyPI.md;build;dist;docs/_build;out;poetry.lock;poetry.toml;run;.coverage;.coverage.lcov;.coveragerc;.gitattributes;.github;.gitignore;.htmlcov;.idea;.mypy_cache;.poetry;.pre-commit-config.yaml;.pylintrc;.pytest_cache;.python-version;.readthedocs.yml;.run;.tabignore;.venv
Expand All @@ -208,7 +208,7 @@ select _pytest_. Under **Docstrings > Docstring format**, select _Google_.

### Running Unit Tests

Right click on the `tests` folder in the project explorer and choose **Run
Right click on the `src/tests` folder in the project explorer and choose **Run
'pytest in tests'**. Make sure that all of the tests pass. If you see a slightly
different option (i.e. for "Unittest" instead of "pytest") then you probably
skipped the preferences setup discussed above. You may need to remove the
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ include = [
{ path='LICENSE', format='sdist' },
{ path='README.md', format='sdist' },
{ path='docs', format='sdist' },
{ path='tests', format='sdist' },
{ path='src/tests', format='sdist' },
{ path='scripts', format='sdist' },
]
classifiers = [
Expand Down Expand Up @@ -115,7 +115,7 @@ pretty = true
show_absolute_path = true
show_column_numbers = true
show_error_codes = true
files = [ "src/uciparse", "tests" ]
files = [ "src" ]
check_untyped_defs = true
disallow_any_generics = true
disallow_incomplete_defs = true
Expand Down
File renamed without changes.
Empty file added src/tests/uciparse/__init__.py
Empty file.
Empty file.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion tests/__init__.py

This file was deleted.

Loading