def test_basename(self) -> None:
        fmt = PackageFormatter()

        self.assertEqual(
            fmt.format('{basename}', Package(name='foo', basename='bar')),
            'bar')
        self.assertEqual(fmt.format('{basename}', Package(name='foo')), 'foo')
    def test_filter_basename(self) -> None:
        fmt = PackageFormatter()

        self.assertEqual(
            fmt.format('{srcname|basename}', spawn_package(srcname='foo/bar')),
            'bar')
        self.assertEqual(
            fmt.format('{srcname|dirname}', spawn_package(srcname='foo/bar')),
            'foo')
    def test_filter_libfirstletter(self) -> None:
        fmt = PackageFormatter()

        self.assertEqual(
            fmt.format('{name|libfirstletter}',
                       Package(name='FOO', version='1.0')), 'f')
        self.assertEqual(
            fmt.format('{name|libfirstletter}',
                       Package(name='LIBFOO', version='1.0')), 'libf')
    def test_filter_stripdmo(self) -> None:
        fmt = PackageFormatter()

        self.assertEqual(
            fmt.format('{name|stripdmo}', spawn_package(name='mplayer')),
            'mplayer')
        self.assertEqual(
            fmt.format('{name|stripdmo}', spawn_package(name='mplayer-dmo')),
            'mplayer')
    def test_incdec(self) -> None:
        fmt = PackageFormatter()

        self.assertEqual(
            fmt.format('{num|inc}',
                       spawn_package(name='foo', extrafields={'num': 'NaN'})),
            '1')
        self.assertEqual(
            fmt.format('{num|inc}',
                       spawn_package(name='foo', extrafields={'num': 1})), '2')
        self.assertEqual(
            fmt.format('{num|dec}',
                       spawn_package(name='foo', extrafields={'num': 1})), '0')
    def test_simple(self) -> None:
        pkg = Package(name='foo',
                      version='1.0',
                      origversion='1.0_1',
                      category='devel',
                      subrepo='main',
                      extrafields={'foo': 'bar'})
        fmt = PackageFormatter()

        self.assertEqual(fmt.format('Just A String', pkg), 'Just A String')
        self.assertEqual(
            fmt.format(
                '{name} {version} {origversion} {category} {subrepo} {foo}',
                pkg), 'foo 1.0 1.0_1 devel main bar')
    def test_filter_lowercase(self) -> None:
        fmt = PackageFormatter()

        self.assertEqual(
            fmt.format('{name|lowercase}', Package(name='FOO', version='1.0')),
            'foo')
    def test_empty_origversion(self):
        fmt = PackageFormatter()

        self.assertEqual(
            fmt.format('{origversion}', Package(name='foo', version='1.0')),
            '1.0')