Skip to content

Commit

Permalink
Merge pull request #67 from chmp/release/0.12.0
Browse files Browse the repository at this point in the history
Release/0.12.0
  • Loading branch information
chmp authored Feb 12, 2022
2 parents b9d8dff + 25903d4 commit e978438
Show file tree
Hide file tree
Showing 20 changed files with 294 additions and 209 deletions.
72 changes: 72 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Changes

Note: development is tracked on the [`develop` branch](https://github.com/chmp/ipytest/tree/develop).

- `0.12.0`:
- Re-add the `raise_on_error` config option
- Return the `exit_code` from `ipyest.run()`
- `0.11.0`:
- Overwrite the program name in pytest error messages for incorrect arguments
- Deprecate `%%run_pytest` and `%%run_pytest[clean]` in favor of `%%ipytest`
- Force color pytest output by default by adding `--color=yes` to the
default `addopts` value
- Configure the number of columns available to pytest
- Add warning and workaround for non-standard IPython implementations
- `0.10.0`:
- Remove the `ModuleCollectorPlugin` in favor of relying on pytest's builtin
collection mechanism
- Allow to fully customize the command line and to skip passing the
current module as an argument
- Simplify config implementation: restrict config changes to function calls
- Allow to use the generated module name in the arguments passed to pytest
by using `{MODULE}`
- Require `python>=3.6`
- Remove `%%rewrite_asserts` magic
- Remove `tempfile_fallback` config option
- Remove `register_module` config option
- Remove `raise_on_error` config option
- Remove `filename` argument for `ipytest.run`
- Remove `return_exit_code` argument from `ipytest.run`
- Remove `running_as_test` function
- `0.9.1`:
- Add `ipython` as an explicit dependency
- `0.9.0`:
- Add `Pytest>=5.4` to the requirements
- Remove legacy functionality, mostly plain unittest integration
- The `tempfile_fallback` also kicks in, if a filename was configured, but
the file does not exist
- Add `register_module` option to register the notebook with the module
system of Python. This way `--doctest-modules` works as expected
- `0.8.1`: release with sdist for conda-forge
- `0.8.0`:
- Add the `autoconfig` helper to simplfy setup with reasonable defaults
- Stop using deprecated pytest API
- `0.7.1`:
- fix assertion rewriting for `pytest>=5.0.0`
- `0.7.0`:
- add option to run tests in separate threads. This change allows to test
async code with the `pytest_asyncio` plugin
- add a proper signature to `ipytest.config(...)` and show the current
settings as a repr.
- `0.6.0`: officially remove python 2 support. While `ipytest` was marked to
work on python 2 and python 3, this statement was not tested and most likely
not true. This change only documents the current state.
- `0.5.0`:
- Fix assertion rewriting via magics in `ipython>=7`
- Add support to raise a `RuntimeError` on test errors (set
`ipytest.config.raise_on_error = True`)
- Add support to set base arguments (set `ipytest.config.addopts = []`)
- Add config setting to enable magics (set `ipytest.config.magics = True`).
- Add config setting to create a temporary file to work without the
notebook filename (set `ipytest.config.tempfile_fallback = True`).
- Allow to set multiple config values at the same time by calling the
config object (`ipytest.config(...)`).
- Add `ipytest.running_as_test()` to detect whether a notebook is executed
as a test.
- `0.4.0`: add support for automatic AST transforms, deprecate non pytest API.
- `0.3.0`: change default pattern for `clean_tests` to match pytest discovery
- `0.2.2`: add support for assert rewriting with current pytest versions
- `0.2.1`: add ipython magics to simplify test execution
- `0.2.0`: support for using pytest inside notebooks
- `0.1.0`: support for running `unittest.FunctionTestCase`,
`unittest.TestCases`, and `doctests`.
1 change: 1 addition & 0 deletions Example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"outputs": [],
"source": [
"import ipytest\n",
"\n",
"ipytest.autoconfig()"
]
},
Expand Down
2 changes: 1 addition & 1 deletion License.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The MIT License (MIT)
Copyright (c) 2015 - 2021 Christopher Prohm
Copyright (c) 2015 - 2022 Christopher Prohm

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
Expand Down
83 changes: 12 additions & 71 deletions Readme.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[Usage](#usage)
| [Global state](#global-state)
| [How does it work?](#how-does-it-work)
| [Changes](#changes)
| [Changes](Changes.md)
| [Reference](#reference)
| [Development](#development)
| [Related packages](#related-packages)
Expand Down Expand Up @@ -63,6 +63,15 @@ work as expected.
[issue-47]: https://github.com/chmp/ipytest/issues/47
[issue-50]: https://github.com/chmp/ipytest/issues/50

**NOTE:** In its default configuration `%%ipytest` and `ipytest.run` will not
raise an error, when tests fail. The reason is that having multiple tracebacks
(the one from pytest and ipytest) may be confusing. To raise exceptions on test
errors, e.g., to use ipytest inside a CI/CD context, use:

```python
ipytest.autoconfig(raise_on_error=True)
```

## Global state

There are multiple sources of global state when using pytest inside the notebook:
Expand Down Expand Up @@ -117,76 +126,6 @@ The arguments are formatted using Python's standard string formatting.
Currently, only the `{MODULE}` variable is understood. It is replaced with the
filename associated with the notebook.

## Changes

Note: development is tracked on the `develop` branch.

- `0.11.0`:
- Overwrite the program name in pytest error messages for incorrect arguments
- Deprecate `%%run_pytest` and `%%run_pytest[clean]` in favor of `%%ipytest`
- Force color pytest output by default by adding `--color=yes` to the
default `addopts` value
- Configure the number of columns available to pytest
- Add warning and workaround for non-standard IPython implementations
- `0.10.0`:
- Remove the `ModuleCollectorPlugin` in favor of relying on pytest's builtin
collection mechanism
- Allow to fully customize the command line and to skip passing the
current module as an argument
- Simplify config implementation: restrict config changes to function calls
- Allow to use the generated module name in the arguments passed to pytest
by using `{MODULE}`
- Require `python>=3.6`
- Remove `%%rewrite_asserts` magic
- Remove `tempfile_fallback` config option
- Remove `register_module` config option
- Remove `raise_on_error` config option
- Remove `filename` argument for `ipytest.run`
- Remove `return_exit_code` argument from `ipytest.run`
- Remove `running_as_test` function
- `0.9.1`:
- Add `ipython` as an explicit dependency
- `0.9.0`:
- Add `Pytest>=5.4` to the requirements
- Remove legacy functionality, mostly plain unittest integration
- The `tempfile_fallback` also kicks in, if a filename was configured, but
the file does not exist
- Add `register_module` option to register the notebook with the module
system of Python. This way `--doctest-modules` works as expected
- `0.8.1`: release with sdist for conda-forge
- `0.8.0`:
- Add the `autoconfig` helper to simplfy setup with reasonable defaults
- Stop using deprecated pytest API
- `0.7.1`:
- fix assertion rewriting for `pytest>=5.0.0`
- `0.7.0`:
- add option to run tests in separate threads. This change allows to test
async code with the `pytest_asyncio` plugin
- add a proper signature to `ipytest.config(...)` and show the current
settings as a repr.
- `0.6.0`: officially remove python 2 support. While `ipytest` was marked to
work on python 2 and python 3, this statement was not tested and most likely
not true. This change only documents the current state.
- `0.5.0`:
- Fix assertion rewriting via magics in `ipython>=7`
- Add support to raise a `RuntimeError` on test errors (set
`ipytest.config.raise_on_error = True`)
- Add support to set base arguments (set `ipytest.config.addopts = []`)
- Add config setting to enable magics (set `ipytest.config.magics = True`).
- Add config setting to create a temporary file to work without the
notebook filename (set `ipytest.config.tempfile_fallback = True`).
- Allow to set multiple config values at the same time by calling the
config object (`ipytest.config(...)`).
- Add `ipytest.running_as_test()` to detect whether a notebook is executed
as a test.
- `0.4.0`: add support for automatic AST transforms, deprecate non pytest API.
- `0.3.0`: change default pattern for `clean_tests` to match pytest discovery
- `0.2.2`: add support for assert rewriting with current pytest versions
- `0.2.1`: add ipython magics to simplify test execution
- `0.2.0`: support for using pytest inside notebooks
- `0.1.0`: support for running `unittest.FunctionTestCase`,
`unittest.TestCases`, and `doctests`.

## Reference

.. autofunction:: ipytest.autoconfig
Expand Down Expand Up @@ -226,6 +165,8 @@ The return code of the last pytest invocation.

.. autofunction:: ipytest.reload

.. autoclass:: ipytest.Error

## Development

Setup the virtual environment via:
Expand Down
103 changes: 28 additions & 75 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[Usage](#usage)
| [Global state](#global-state)
| [How does it work?](#how-does-it-work)
| [Changes](#changes)
| [Changes](Changes.md)
| [Reference](#reference)
| [Development](#development)
| [Related packages](#related-packages)
Expand Down Expand Up @@ -63,6 +63,15 @@ work as expected.
[issue-47]: https://github.com/chmp/ipytest/issues/47
[issue-50]: https://github.com/chmp/ipytest/issues/50

**NOTE:** In its default configuration `%%ipytest` and `ipytest.run` will not
raise an error, when tests fail. The reason is that having multiple tracebacks
(the one from pytest and ipytest) may be confusing. To raise exceptions on test
errors, e.g., to use ipytest inside a CI/CD context, use:

```python
ipytest.autoconfig(raise_on_error=True)
```

## Global state

There are multiple sources of global state when using pytest inside the notebook:
Expand Down Expand Up @@ -117,80 +126,10 @@ The arguments are formatted using Python's standard string formatting.
Currently, only the `{MODULE}` variable is understood. It is replaced with the
filename associated with the notebook.

## Changes

Note: development is tracked on the `develop` branch.

- `0.11.0`:
- Overwrite the program name in pytest error messages for incorrect arguments
- Deprecate `%%run_pytest` and `%%run_pytest[clean]` in favor of `%%ipytest`
- Force color pytest output by default by adding `--color=yes` to the
default `addopts` value
- Configure the number of columns available to pytest
- Add warning and workaround for non-standard IPython implementations
- `0.10.0`:
- Remove the `ModuleCollectorPlugin` in favor of relying on pytest's builtin
collection mechanism
- Allow to fully customize the command line and to skip passing the
current module as an argument
- Simplify config implementation: restrict config changes to function calls
- Allow to use the generated module name in the arguments passed to pytest
by using `{MODULE}`
- Require `python>=3.6`
- Remove `%%rewrite_asserts` magic
- Remove `tempfile_fallback` config option
- Remove `register_module` config option
- Remove `raise_on_error` config option
- Remove `filename` argument for `ipytest.run`
- Remove `return_exit_code` argument from `ipytest.run`
- Remove `running_as_test` function
- `0.9.1`:
- Add `ipython` as an explicit dependency
- `0.9.0`:
- Add `Pytest>=5.4` to the requirements
- Remove legacy functionality, mostly plain unittest integration
- The `tempfile_fallback` also kicks in, if a filename was configured, but
the file does not exist
- Add `register_module` option to register the notebook with the module
system of Python. This way `--doctest-modules` works as expected
- `0.8.1`: release with sdist for conda-forge
- `0.8.0`:
- Add the `autoconfig` helper to simplfy setup with reasonable defaults
- Stop using deprecated pytest API
- `0.7.1`:
- fix assertion rewriting for `pytest>=5.0.0`
- `0.7.0`:
- add option to run tests in separate threads. This change allows to test
async code with the `pytest_asyncio` plugin
- add a proper signature to `ipytest.config(...)` and show the current
settings as a repr.
- `0.6.0`: officially remove python 2 support. While `ipytest` was marked to
work on python 2 and python 3, this statement was not tested and most likely
not true. This change only documents the current state.
- `0.5.0`:
- Fix assertion rewriting via magics in `ipython>=7`
- Add support to raise a `RuntimeError` on test errors (set
`ipytest.config.raise_on_error = True`)
- Add support to set base arguments (set `ipytest.config.addopts = []`)
- Add config setting to enable magics (set `ipytest.config.magics = True`).
- Add config setting to create a temporary file to work without the
notebook filename (set `ipytest.config.tempfile_fallback = True`).
- Allow to set multiple config values at the same time by calling the
config object (`ipytest.config(...)`).
- Add `ipytest.running_as_test()` to detect whether a notebook is executed
as a test.
- `0.4.0`: add support for automatic AST transforms, deprecate non pytest API.
- `0.3.0`: change default pattern for `clean_tests` to match pytest discovery
- `0.2.2`: add support for assert rewriting with current pytest versions
- `0.2.1`: add ipython magics to simplify test execution
- `0.2.0`: support for using pytest inside notebooks
- `0.1.0`: support for running `unittest.FunctionTestCase`,
`unittest.TestCases`, and `doctests`.

## Reference

### `ipytest.autoconfig`
`ipytest.autoconfig(rewrite_asserts=<default>, magics=<default>, clean=<default>, addopts=<default>, run_in_thread=<default>, defopts=<default>, display_columns=<default>)`
`ipytest.autoconfig(rewrite_asserts=<default>, magics=<default>, clean=<default>, addopts=<default>, run_in_thread=<default>, defopts=<default>, display_columns=<default>, raise_on_error=<default>)`

Configure `ipytest` with reasonable defaults.

Expand All @@ -203,6 +142,7 @@ Specifically, it sets:
- `run_in_thread`: `False`
- `defopts`: `True`
- `display_columns`: `100`
- `raise_on_error`: `False`

See [ipytest.config](#ipytestconfig) for details.

Expand Down Expand Up @@ -232,7 +172,7 @@ def test_example():
```

### `ipytest.config`
`ipytest.config(rewrite_asserts=<keep>, magics=<keep>, clean=<keep>, addopts=<keep>, run_in_thread=<keep>, defopts=<keep>, display_columns=<keep>)`
`ipytest.config(rewrite_asserts=<keep>, magics=<keep>, clean=<keep>, addopts=<keep>, run_in_thread=<keep>, defopts=<keep>, display_columns=<keep>, raise_on_error=<keep>)`

Configure ipytest

Expand Down Expand Up @@ -260,9 +200,11 @@ The following settings are supported:
current module to the arguments passed to pytest. If `False` only the
arguments given and `adopts` are passed. Such a setup may be helpful
to customize the test selection
- `display_columns` (default: `100`) if not False, configure Pytest
- `display_columns` (default: `100`): if not `False`, configure Pytest
to use the given number of columns for its output. This option will
temporarily override the `COLUMNS` environment variable.
- `raise_on_error` (default `False` ): if `True`, `ipytest.run`
and `%%ipytest` will raise an `ipytest.Error` if pytest fails.



Expand All @@ -289,6 +231,10 @@ Execute all tests in the passed module (defaults to __main__) with pytest.
* **plugins** (*any*):
additional plugins passed to pytest.

#### Returns

the exit code of pytest.main.



### `ipytest.clean_tests`
Expand Down Expand Up @@ -329,6 +275,13 @@ reload("ipytest._util", "ipytest")



### `ipytest.Error`
`ipytest.Error(exit_code)`

Error raised by ipytest on test failure



## Development

Setup the virtual environment via:
Expand Down Expand Up @@ -374,7 +327,7 @@ Please create an issue, if I missed a packaged or mischaracterized any package.

```
The MIT License (MIT)
Copyright (c) 2015 - 2021 Christopher Prohm
Copyright (c) 2015 - 2022 Christopher Prohm
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
Expand Down
3 changes: 2 additions & 1 deletion ipytest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from ._config import config, autoconfig
from ._impl import clean_tests, reload, run
from ._impl import clean_tests, reload, run, Error

# the pytest exit code
exit_code = None
Expand All @@ -12,4 +12,5 @@
"clean_tests",
"reload",
"running_as_test",
"Error",
]
Loading

0 comments on commit e978438

Please sign in to comment.