コード例 #1
0
ファイル: footnotes_test.py プロジェクト: Daniil-Sokolov/grow
    def test_locale_pattern(self):
        notes = footnotes.Footnotes(None)
        self.assertEquals(False, notes.is_numeric)

        notes = footnotes.Footnotes('de_DE')
        self.assertEquals(True, notes.is_numeric)

        notes = footnotes.Footnotes('en_US')
        self.assertEquals(False, notes.is_numeric)
コード例 #2
0
ファイル: footnotes_test.py プロジェクト: Daniil-Sokolov/grow
 def test_add(self):
     notes = footnotes.Footnotes(None)
     symbol = notes.add('See other side.')
     self.assertEquals(1, len(notes))
     self.assertEquals('*', symbol)
     self.assertEquals('See other side.', notes[symbol])
     self.assertDictEqual({'*': 'See other side.'}, notes.footnotes)
コード例 #3
0
ファイル: footnotes_test.py プロジェクト: cdhermann/grow
 def test_add_custom_symbol(self):
     notes = footnotes.Footnotes(None)
     symbol = notes.add('See other side.', custom_symbol='^')
     self.assertEqual(1, len(notes))
     self.assertEqual('^', symbol)
     self.assertEqual('See other side.', notes[symbol])
     self.assertDictEqual({'^': 'See other side.'}, notes.footnotes)
コード例 #4
0
ファイル: footnotes_test.py プロジェクト: Daniil-Sokolov/grow
 def test_add_duplicate(self):
     # Adding duplicate footnotes does not create new footnotes.
     notes = footnotes.Footnotes(None)
     symbol = notes.add('See other side.')
     self.assertEquals(1, len(notes))
     self.assertEquals('*', symbol)
     symbol = notes.add('See other side.')
     self.assertEquals(1, len(notes))
     self.assertEquals('*', symbol)
コード例 #5
0
ファイル: footnotes_test.py プロジェクト: cdhermann/grow
    def test_add_custom_symbol_duplicate(self):
        notes = footnotes.Footnotes(None)
        notes.add('See other side.', custom_symbol='^')

        # Adding with the same note does not error.
        notes.add('See other side.', custom_symbol='^')

        # Adding with same symbol, but different note errors.
        with self.assertRaises(DuplicateSymbolError):
            notes.add('See this side.', custom_symbol='^')
コード例 #6
0
ファイル: document.py プロジェクト: david-j-davis/grow
 def footnotes(self):
     # Configure the footnotes based on the doc or podspec settings.
     footnote_config = self.fields.get(
         '$footnotes', self.pod.podspec.fields.get('footnotes', {}))
     locale = str(self.locale) if self.locale else None
     symbols = footnote_config.get('symbols', None)
     use_numeric_symbols = footnote_config.get('use_numeric_symbols', None)
     numeric_locales_pattern = footnote_config.get(
         'numeric_locales_pattern', None)
     return footnotes.Footnotes(
         locale, symbols=symbols, use_numeric_symbols=use_numeric_symbols,
         numeric_locales_pattern=numeric_locales_pattern)
コード例 #7
0
ファイル: footnotes_test.py プロジェクト: rsau/grow
    def test_use_numeric_symbols(self):
        # Defaults to pattern for detection.
        notes = footnotes.Footnotes('de_DE')
        self.assertEquals(True, notes.is_numeric)

        notes = footnotes.Footnotes('en_US')
        self.assertEquals(False, notes.is_numeric)

        # Ignores the pattern when false.
        notes = footnotes.Footnotes(
            'de_DE', use_numeric_symbols=False)
        self.assertEquals(False, notes.is_numeric)

        notes = footnotes.Footnotes(
            'en_US', use_numeric_symbols=False)
        self.assertEquals(False, notes.is_numeric)

        # Ignores the pattern when true.
        notes = footnotes.Footnotes(
            'de_DE', use_numeric_symbols=True)
        self.assertEquals(True, notes.is_numeric)

        notes = footnotes.Footnotes(
            'en_US', use_numeric_symbols=True)
        self.assertEquals(True, notes.is_numeric)
コード例 #8
0
ファイル: footnotes_test.py プロジェクト: willthomson/grow
    def test_reset(self):
        """Resetting resets the footnotes and the symbol generator."""
        notes = footnotes.Footnotes(None)
        symbol = notes.add('See other side.')
        self.assertEquals(1, len(notes))
        self.assertEquals('*', symbol)
        self.assertEquals('See other side.', notes[symbol])

        notes.reset()

        self.assertEquals(0, len(notes))
        symbol = notes.add('See this side.')
        self.assertEquals(1, len(notes))
        self.assertEquals('*', symbol)
        self.assertEquals('See this side.', notes[symbol])
コード例 #9
0
ファイル: footnotes_test.py プロジェクト: Daniil-Sokolov/grow
 def test_locale_pattern_custom(self):
     notes = footnotes.Footnotes('en_US', numeric_locales_pattern='_US$')
     self.assertEquals(True, notes.is_numeric)
コード例 #10
0
ファイル: footnotes_test.py プロジェクト: Daniil-Sokolov/grow
 def test_index(self):
     notes = footnotes.Footnotes(None)
     symbol = notes.add('See other side.')
     self.assertEquals(0, notes.index(symbol))
     symbol = notes.add('Nothing to see here.')
     self.assertEquals(1, notes.index(symbol))