Loading .gitignore 0 → 100644 +2 −0 Original line number Diff line number Diff line # Python (for tests) *.py[co] .lint.cfg 0 → 100644 +104 −0 Original line number Diff line number Diff line [isort] force_single_line = true [mypy] strict = true warn_unused_configs = true warn_unreachable = true ;implicit_reexport = true mypy_path = tests/stubs plugins = trio_typing.plugin [flake8] max-line-length = 92 max-doc-length = 92 use-flake8-tabs = true blank-lines-indent = never indent-tabs-def = 1 format = pylint select = C,D,E,ET,F,SFS,T,W,WT per-file-ignores = **/__init__.py: D104 **/__main__.py: D100, E702 ignore = ;[ '%s' imported but unused ] ; Handled by pylint, which does it better F401 ;[ Missing docstring in public method ] ; Handled by pylint, which does it better D102 ;[ Missing docstring in magic method ] ; Magic/dunder methods are well-known D105 ;[ Misisng docstring in __init__ ] ; Document basic construction in the class docstring D107 ;[ One-line docstring should fit on one line with quotes ] ; Prefer top-and-bottom style always D200 ;[ Docstring should be indented with spaces, not tabs ] ; Tabs, absolutely always D206 ;[ Use r""" if any backslashes in a docstring ] ; If I want to put escape chars in a docstring, I will D301 ;[ Use u""" for Unicode docstrings ] ; This must be for Python 2? D302 ;[ First line should end with a period ] ; First line should *NEVER* end with a period D400 ;[ First line should be in the imperative mood ] ; I like this for functions and methods, not for properties. This stands until ; pydocstyle splits a new code for properties or flake8 adds some way of ; filtering codes with line regexes like golangci-lint. D401 ;[ No blank lines allowed between a section header and its content ] D412 ;[ missing whitespace around bitwise or shift operator ] E227 ;[ Line too long ] ; Prefer B950 implementation E501 ;[ multiple statements on one line (def) ] ; Dosen't work well with short @overload definitions E704 ;[ unexpected number of tabs and spaces at start of statement ] ET128 ;[ Line break before binary operator ] ; Not considered current W503 ;[ Format-method string formatting ] ; Allow this style SFS201 ;[ f-string string formatting ] ; Allow this style SFS301 include = ;[ First word of the docstring should not be This ] D404 ; flake8-bugbear plugin ; B950 is a replacement for E501 B0 B903 B950 .pre-commit-config.yaml +60 −0 Original line number Diff line number Diff line Loading @@ -11,13 +11,17 @@ repos: hooks: - id: check-added-large-files - id: check-case-conflict - id: check-docstring-first - id: check-merge-conflict - id: check-yaml args: [--allow-multiple-documents] - id: debug-statements - id: destroyed-symlinks - id: end-of-file-fixer stages: [commit, manual] - id: fix-byte-order-marker - id: fix-encoding-pragma args: [--remove] - id: mixed-line-ending args: [--fix=lf] stages: [commit, manual] Loading @@ -38,3 +42,59 @@ repos: - id: copyright-notice exclude: ^data/ - id: protect-first-parent - repo: https://github.com/pre-commit/pygrep-hooks rev: v1.8.0 hooks: - id: python-no-eval - id: python-no-log-warn - id: python-use-type-annotations - repo: https://github.com/hakancelik96/unimport rev: 0.9.2 hooks: - id: unimport args: ["--remove", "--include=\\.pyi?$"] types: [] types_or: [python, pyi] stages: [commit, manual] - repo: https://github.com/pycqa/isort rev: 5.9.3 hooks: - id: isort args: ["--settings=.lint.cfg"] stages: [commit, manual] - repo: https://github.com/asottile/add-trailing-comma rev: v2.1.0 hooks: - id: add-trailing-comma args: [--py36-plus] types: [] types_or: [python, pyi] stages: [commit, manual] - repo: https://gitlab.com/pycqa/flake8 rev: 3.8.4 hooks: - id: flake8 args: ["--config=.lint.cfg"] additional_dependencies: - flake8-bugbear - flake8-docstrings - flake8-print - flake8-requirements - flake8-return - flake8-sfs - flake8-tabs - repo: https://github.com/pre-commit/mirrors-mypy rev: v0.910 hooks: - id: mypy args: ["--config-file=.lint.cfg"] additional_dependencies: - trio-typing - types-requests - git+https://code.kodo.org.uk/dom/type-stubs.git#type-stubs[jsonpath,parse] behave.ini 0 → 100644 +2 −0 Original line number Diff line number Diff line [behave] paths = tests tests/README.md 0 → 100644 +74 −0 Original line number Diff line number Diff line Behaviour Testing ================= These behaviour tests use "Behave", a Python framework. Requirements ------------ ### Docker (>=18.09) Docker is required for running the project; a minimum version of 18.09 is required to build the images. ### Python (>=3.9) The tests are coordinated and run by "behave", a Python testing framework. In order to check the correctness of the test code it has been written with the latest typing features of Python. Installing ---------- There are a small number of Python package dependencies listed in [requirements.txt]() which must be installed; it is recommended that they are installed in a [virtual environment][venv]: ```bash env=venv # You may choose any directory name here python -m venv $env $env/bin/python -m pip install -r tests/requirements.txt ``` ### OPTIONAL: Make `behave` runnable without a full path The virtual environment's *bin/* directory (*Scripts/* for Windows builds of Python) can be added to the executable search variable "PATH". This will make `behave` and other installed tools runnable without having to supply a full path to the executable. The 'venv' tool supplies handy scripts for this purpose. All the following example in this document assume this has been done; if not simply replace `behave` with `$env/bin/behave` where `$env` expands to the virtual environment created above. For Bash and Zsh use the following, for other shells see the [venv][] documentation: ```bash source $env/bin/activate ``` [venv]: https://docs.python.org/3/library/venv.html "Documentation for 'venv'" Usage ----- From the top directory of the project or the *tests* subdirectory, Behave can be called with no arguments to run all scenarios: ```bash behave ``` Behave can be run with path arguments in which case it can be run from any directory. Feature files (matching `*.feature`) may be specified to run their scenarios, or if the path is a directory the tree will be searched for feature files. ```bash behave tests # Run scenarios for all features behave tests/regression-*.feature # Run regression scenarios ``` Loading
.gitignore 0 → 100644 +2 −0 Original line number Diff line number Diff line # Python (for tests) *.py[co]
.lint.cfg 0 → 100644 +104 −0 Original line number Diff line number Diff line [isort] force_single_line = true [mypy] strict = true warn_unused_configs = true warn_unreachable = true ;implicit_reexport = true mypy_path = tests/stubs plugins = trio_typing.plugin [flake8] max-line-length = 92 max-doc-length = 92 use-flake8-tabs = true blank-lines-indent = never indent-tabs-def = 1 format = pylint select = C,D,E,ET,F,SFS,T,W,WT per-file-ignores = **/__init__.py: D104 **/__main__.py: D100, E702 ignore = ;[ '%s' imported but unused ] ; Handled by pylint, which does it better F401 ;[ Missing docstring in public method ] ; Handled by pylint, which does it better D102 ;[ Missing docstring in magic method ] ; Magic/dunder methods are well-known D105 ;[ Misisng docstring in __init__ ] ; Document basic construction in the class docstring D107 ;[ One-line docstring should fit on one line with quotes ] ; Prefer top-and-bottom style always D200 ;[ Docstring should be indented with spaces, not tabs ] ; Tabs, absolutely always D206 ;[ Use r""" if any backslashes in a docstring ] ; If I want to put escape chars in a docstring, I will D301 ;[ Use u""" for Unicode docstrings ] ; This must be for Python 2? D302 ;[ First line should end with a period ] ; First line should *NEVER* end with a period D400 ;[ First line should be in the imperative mood ] ; I like this for functions and methods, not for properties. This stands until ; pydocstyle splits a new code for properties or flake8 adds some way of ; filtering codes with line regexes like golangci-lint. D401 ;[ No blank lines allowed between a section header and its content ] D412 ;[ missing whitespace around bitwise or shift operator ] E227 ;[ Line too long ] ; Prefer B950 implementation E501 ;[ multiple statements on one line (def) ] ; Dosen't work well with short @overload definitions E704 ;[ unexpected number of tabs and spaces at start of statement ] ET128 ;[ Line break before binary operator ] ; Not considered current W503 ;[ Format-method string formatting ] ; Allow this style SFS201 ;[ f-string string formatting ] ; Allow this style SFS301 include = ;[ First word of the docstring should not be This ] D404 ; flake8-bugbear plugin ; B950 is a replacement for E501 B0 B903 B950
.pre-commit-config.yaml +60 −0 Original line number Diff line number Diff line Loading @@ -11,13 +11,17 @@ repos: hooks: - id: check-added-large-files - id: check-case-conflict - id: check-docstring-first - id: check-merge-conflict - id: check-yaml args: [--allow-multiple-documents] - id: debug-statements - id: destroyed-symlinks - id: end-of-file-fixer stages: [commit, manual] - id: fix-byte-order-marker - id: fix-encoding-pragma args: [--remove] - id: mixed-line-ending args: [--fix=lf] stages: [commit, manual] Loading @@ -38,3 +42,59 @@ repos: - id: copyright-notice exclude: ^data/ - id: protect-first-parent - repo: https://github.com/pre-commit/pygrep-hooks rev: v1.8.0 hooks: - id: python-no-eval - id: python-no-log-warn - id: python-use-type-annotations - repo: https://github.com/hakancelik96/unimport rev: 0.9.2 hooks: - id: unimport args: ["--remove", "--include=\\.pyi?$"] types: [] types_or: [python, pyi] stages: [commit, manual] - repo: https://github.com/pycqa/isort rev: 5.9.3 hooks: - id: isort args: ["--settings=.lint.cfg"] stages: [commit, manual] - repo: https://github.com/asottile/add-trailing-comma rev: v2.1.0 hooks: - id: add-trailing-comma args: [--py36-plus] types: [] types_or: [python, pyi] stages: [commit, manual] - repo: https://gitlab.com/pycqa/flake8 rev: 3.8.4 hooks: - id: flake8 args: ["--config=.lint.cfg"] additional_dependencies: - flake8-bugbear - flake8-docstrings - flake8-print - flake8-requirements - flake8-return - flake8-sfs - flake8-tabs - repo: https://github.com/pre-commit/mirrors-mypy rev: v0.910 hooks: - id: mypy args: ["--config-file=.lint.cfg"] additional_dependencies: - trio-typing - types-requests - git+https://code.kodo.org.uk/dom/type-stubs.git#type-stubs[jsonpath,parse]
tests/README.md 0 → 100644 +74 −0 Original line number Diff line number Diff line Behaviour Testing ================= These behaviour tests use "Behave", a Python framework. Requirements ------------ ### Docker (>=18.09) Docker is required for running the project; a minimum version of 18.09 is required to build the images. ### Python (>=3.9) The tests are coordinated and run by "behave", a Python testing framework. In order to check the correctness of the test code it has been written with the latest typing features of Python. Installing ---------- There are a small number of Python package dependencies listed in [requirements.txt]() which must be installed; it is recommended that they are installed in a [virtual environment][venv]: ```bash env=venv # You may choose any directory name here python -m venv $env $env/bin/python -m pip install -r tests/requirements.txt ``` ### OPTIONAL: Make `behave` runnable without a full path The virtual environment's *bin/* directory (*Scripts/* for Windows builds of Python) can be added to the executable search variable "PATH". This will make `behave` and other installed tools runnable without having to supply a full path to the executable. The 'venv' tool supplies handy scripts for this purpose. All the following example in this document assume this has been done; if not simply replace `behave` with `$env/bin/behave` where `$env` expands to the virtual environment created above. For Bash and Zsh use the following, for other shells see the [venv][] documentation: ```bash source $env/bin/activate ``` [venv]: https://docs.python.org/3/library/venv.html "Documentation for 'venv'" Usage ----- From the top directory of the project or the *tests* subdirectory, Behave can be called with no arguments to run all scenarios: ```bash behave ``` Behave can be run with path arguments in which case it can be run from any directory. Feature files (matching `*.feature`) may be specified to run their scenarios, or if the path is a directory the tree will be searched for feature files. ```bash behave tests # Run scenarios for all features behave tests/regression-*.feature # Run regression scenarios ```