obspy.core.util.base.CatchAndAssertWarnings

class CatchAndAssertWarnings(clear=None, expected=None, show_all=True, **kwargs)[source]

Bases: catch_warnings

Public Methods

clear_warning_registry

Clear warning registry of specified module

Private Methods

Warning

Private methods are mainly for internal/developer use and their API might change without notice.

CatchAndAssertWarnings._assert_warnings()[source]

Checks for expected warnings and raises an AssertionError if anyone of these is not encountered.

Special Methods

CatchAndAssertWarnings.__delattr__(name, /)

Implement delattr(self, name).

CatchAndAssertWarnings.__dir__()

Default dir() implementation.

CatchAndAssertWarnings.__enter__()[source]
CatchAndAssertWarnings.__eq__(value, /)

Return self==value.

CatchAndAssertWarnings.__exit__(*exc_info)[source]
CatchAndAssertWarnings.__format__(format_spec, /)

Default object formatter.

CatchAndAssertWarnings.__ge__(value, /)

Return self>=value.

CatchAndAssertWarnings.__getattribute__(name, /)

Return getattr(self, name).

CatchAndAssertWarnings.__gt__(value, /)

Return self>value.

CatchAndAssertWarnings.__hash__()

Return hash(self).

CatchAndAssertWarnings.__init__(clear=None, expected=None, show_all=True, **kwargs)[source]
Parameters:
  • clear (list[str]) – list of modules to clear warning registries on (e.g. ["obspy.signal", "obspy.core"]), in order to make sure any expected warnings will be shown and not suppressed because already raised in previously executed code.

  • expected (list) – list of 2-tuples specifying expected warnings that should be looked for when exiting the context manager. An AssertionError will be raised if any expected warning is not encountered. First item in tuple should be the class of the warning, second item should be a regex matching (a part of) the warning message (e.g. (ObsPyDeprecationWarning, 'Attribute .* is deprecated')). Make sure to escape regex special characters like ( or . with a backslash and provide message regex as a raw string.

  • show_all (str) – Whether to set warnings.simplefilter('always') when entering context.

CatchAndAssertWarnings.__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

CatchAndAssertWarnings.__le__(value, /)

Return self<=value.

CatchAndAssertWarnings.__lt__(value, /)

Return self<value.

CatchAndAssertWarnings.__ne__(value, /)

Return self!=value.

CatchAndAssertWarnings.__new__(**kwargs)
CatchAndAssertWarnings.__reduce__()

Helper for pickle.

CatchAndAssertWarnings.__reduce_ex__(protocol, /)

Helper for pickle.

CatchAndAssertWarnings.__repr__()
CatchAndAssertWarnings.__setattr__(name, value, /)

Implement setattr(self, name, value).

CatchAndAssertWarnings.__sizeof__()

Size of object in memory, in bytes.

CatchAndAssertWarnings.__str__()

Return str(self).

CatchAndAssertWarnings.__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).