# Testing


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

``` python
```

    The autoreload extension is already loaded. To reload it, use:
      %reload_ext autoreload

------------------------------------------------------------------------

### ExceptionInfo

``` python

def ExceptionInfo(
    type_:type[Exception] | None=None, value:Exception | None=None, traceback:str | None=None
)->None:

```

<details open class="code-fold">
<summary>Exported source</summary>

``` python
@dataclass
class ExceptionInfo:
    type_: type[Exception] | None = None
    value: Exception | None = None
    traceback: str | None = None
```

</details>

------------------------------------------------------------------------

### raises

``` python

def raises(
    exc:type=Exception, # The exception type to check is raised.
    contains:str | None=None, # Optionally, check whether the raised exception contains this message.
)->Generator:

```

*Asserts that the body of the context manager raises `exc`.*

<details open class="code-fold">
<summary>Exported source</summary>

``` python
@contextlib.contextmanager
def raises(
    exc: type[Exception] = Exception,  # The exception type to check is raised.
    contains: str | None = None,  # Optionally, check whether the raised exception contains this message.
) -> Generator[ExceptionInfo, None, None]:
    "Asserts that the body of the context manager raises `exc`."
    raised = True
    try:
        info = ExceptionInfo()
        yield info
        raised = False
    except exc as e:
        info.type_ = type(e)
        info.value = e
        info.traceback = traceback.format_tb(e.__traceback__)
        if contains and contains not in str(e):
            raise AssertionError(f"Raised {e} but message does not contain {contains}") from e
    if not raised:
        raise AssertionError(f"Did not raise {e}")
```

</details>

``` python
with raises() as e:
    raise Exception("abc")
print(e)
```

    ExceptionInfo(type_=<class 'Exception'>, value=Exception('abc'), traceback=['  File "/tmp/ipykernel_2029/2204637686.py", line 11, in raises\n    yield info\n', '  File "/tmp/ipykernel_2029/3922684010.py", line 2, in <module>\n    raise Exception("abc")\n'])

------------------------------------------------------------------------

### equal

``` python

def equal(
    a, b
):

```

*Assert that a == b.*

<details open class="code-fold">
<summary>Exported source</summary>

``` python
def equal(a, b):
    "Assert that a == b."
    args_src, _ = get_call_args()
    if a != b:
        msg = (
            f"FAIL: {args_src[0]} != {args_src[1]}\n" +
            ' ' * (len(AssertionError.__name__)+2) +
            f"      {a!r} != {b!r}"
        )
        raise AssertionError(msg)
```

</details>

``` python
with raises(exc=AssertionError) as e:
    equal(1, 2)
```
