| |
@@ -55,6 +55,78 @@
|
| |
%generate_buildrequires
|
| |
%pyproject_buildrequires -r -x testing
|
| |
|
| |
+ For projects that specify test requirements in their [tox] configuration,
|
| |
+ these can be added using the `-t` flag (default tox environment)
|
| |
+ or the `-e` flag followed by the tox environment.
|
| |
+ The default tox environment (such as `py37` assuming the Fedora's Python version is 3.7)
|
| |
+ is available in the `%{toxenv}` macro.
|
| |
+ For example, if upstream suggests running the tests on Python 3.7 with `tox -e py37`,
|
| |
+ the test deps would be generated by:
|
| |
+
|
| |
+ %generate_buildrequires
|
| |
+ %pyproject_buildrequires -t
|
| |
+
|
| |
+ If upstream uses a custom derived environment, such as `py37-unit`, use:
|
| |
+
|
| |
+ %pyproject_buildrequires -e %{toxenv}-unit
|
| |
+
|
| |
+ Or specify more environments if needed:
|
| |
+
|
| |
+ %pyproject_buildrequires -e %{toxenv}-unit,%{toxenv}-integration
|
| |
+
|
| |
+ The `-e` option redefines `%{toxenv}` for further reuse.
|
| |
+ Use `%{default_toxenv}` to get the default value.
|
| |
+
|
| |
+ Note that `-t` implies `-r`, because tox normally assumes the package is installed
|
| |
+ including all the runtime dependencies.
|
| |
+
|
| |
+ The `-t`/`-e` option uses [tox-current-env]'s `--print-deps-to-file` behind the scenes.
|
| |
+
|
| |
+ [tox]: https://tox.readthedocs.io/
|
| |
+ [tox-current-env]: https://github.com/fedora-python/tox-current-env/
|
| |
+
|
| |
+
|
| |
+ Running tox based tests
|
| |
+ -----------------------
|
| |
+
|
| |
+ In case you want to run the tests as specified in [tox] configuration,
|
| |
+ you can use the `%tox` macro:
|
| |
+
|
| |
+ %check
|
| |
+ %tox
|
| |
+
|
| |
+ The macro:
|
| |
+
|
| |
+ - Always prepends `$PATH` with `%{buildroot}%{_bindir}`
|
| |
+ - If not defined, sets `$PYTHONPATH` to `%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}`
|
| |
+ - If not defined, sets `$TOX_TESTENV_PASSENV` to `*`
|
| |
+ - Runs `tox` with `-q` (quiet), `--recreate` and `--current-env` (from [tox-current-env]) flags
|
| |
+ - Implicitly uses the tox environment name stored in `%{toxenv}` - as overridden by `%pyproject_buildrequires -t`
|
| |
+
|
| |
+ By using the `-e` flag, you can use a different tox environment(s):
|
| |
+
|
| |
+ %check
|
| |
+ %tox
|
| |
+ %if %{with integration_test}
|
| |
+ %tox -e % {default_toxenv}-integration
|
| |
+ %endif
|
| |
+
|
| |
+ If you wish to provide custom `tox` flags or arguments, add them after `--`:
|
| |
+
|
| |
+ %tox -- --flag-for-tox
|
| |
+
|
| |
+ If you wish to pass custom `posargs` to tox, use another `--`:
|
| |
+
|
| |
+ %tox -- --flag-for-tox -- --flag-for-posargs
|
| |
+
|
| |
+ Or (note the two sequential `--`s):
|
| |
+
|
| |
+ %tox -- -- --flag-for-posargs
|
| |
+
|
| |
+ **Warning:** This macro assumes you have used `%pyproject_buildrequires -t` or `-e`
|
| |
+ in `%generate_buildrequires`. If not, you need to add:
|
| |
+
|
| |
+ BuildRequires: python3dist(tox-current-env)
|
| |
|
| |
Limitations
|
| |
-----------
|
| |
@@ -64,9 +136,6 @@
|
| |
This macro changes shebang lines of every Python script in `%{buildroot}%{_bindir}` to `#! %{__python3} %{py3_shbang_opt}` (`#! /usr/bin/python3 -s`).
|
| |
We plan to preserve existing Python flags in shebangs, but the work is not yet finished.
|
| |
|
| |
- The PEPs don't (yet) define a way to specify test dependencies and test runners.
|
| |
- That means you still need to handle test dependencies and `%check` on your own.
|
| |
-
|
| |
Extras are currently ignored.
|
| |
|
| |
Some valid Python version specifiers are not supported.
|
| |
TODO: Figure out how to make-t %{toxenv}
the default when-t
is used without argument. (Not necessarily blocks this PR.)