Пример #1
0
    def abbreviate_fqdn(self, name: str, *, prefix: str = '') -> str:
        """Abbreviate fully-qualified Python name, by removing origin.

        ``app.conf.origin`` is the package where the app is defined,
        so if this is ``examples.simple`` it returns the truncated::

            >>> app.conf.origin
            'examples.simple'
            >>> abbr_fqdn(app.conf.origin,
            ...           'examples.simple.Withdrawal',
            ...           prefix='[...]')
            '[...]Withdrawal'

        but if the package is not part of origin it provides the full path::

            >>> abbr_fqdn(app.conf.origin,
            ...           'examples.other.Foo', prefix='[...]')
            'examples.other.foo'
        """
        return text.abbr_fqdn(self.app.conf.origin, name, prefix=prefix)
Пример #2
0
def test_abbr_fqdn(origin, name, prefix, expected):
    assert text.abbr_fqdn(origin, name, prefix=prefix) == expected