Пример #1
0
 def test_apostrophes(self):
     self.assertEqual(
         wc.wc('', "Madison's James")['counts']['words'], 2,
         'possessive apostrophe with s')
     self.assertEqual(
         wc.wc('', "James' Madison")['counts']['words'], 2,
         'possessive apostrophe with no s')
Пример #2
0
 def test_hyphens(self):
     self.assertEqual(
         wc.wc('', 'a - b')['counts']['words'], 2, 'hyphen and two spaces')
     self.assertEqual(
         wc.wc('', 'a- b')['counts']['words'], 2, 'hyphen and one space')
     self.assertEqual(
         wc.wc('', 'a-b')['counts']['words'], 1, 'hyphen and no spaces')
Пример #3
0
 def test_ellipses(self):
     self.assertEqual(
         wc.wc('', 'a . . . b')['counts']['words'], 2,
         'spaced ellipses and two spaces')
     self.assertEqual(
         wc.wc('', 'a. . .b')['counts']['words'], 2,
         'spaced ellipses and no spaces')
     self.assertEqual(
         wc.wc('', 'a ... b')['counts']['words'], 2,
         'unspaced ellipses and two spaces')
     self.assertEqual(
         wc.wc('', 'a... b')['counts']['words'], 2,
         'unspaced ellipses and one space')
     self.assertEqual(
         wc.wc('', 'a...b')['counts']['words'], 2,
         'unspaced ellipses and no spaces')
Пример #4
0
 def test_nonjekyll(self):
     result = wc.wc('non-jekyll', self.plaintext)
     self.assertEqual(
         result, {
             'counts': {
                 'characters_real': 198,
                 'characters_total': 268,
                 'file': 'non-jekyll',
                 'paragraphs': 1,
                 'type': 'md/txt',
                 'words': 46,
             }
         })
Пример #5
0
 def save(self, *args, **kwargs):
     self.ctime = timezone.now()
     self.cover = markdown.markdown(
         self.cover, extensions=['markdown.extensions.extra'])
     process_file = (kwargs.pop('process_file')
                     if 'process_file' in kwargs else False)
     if process_file:
         self.submission_text = markdown.markdown(
             pypandoc.convert_file(self.original_file.path, 'md'))
         self.wordcount = wc.wc(
             None, pypandoc.convert(
                 self.submission_text, 'plain', 'html'))['counts']['words']
     super(Submission, self).save(*args, **kwargs)
Пример #6
0
 def test_jekyll(self):
     result = wc.wc('jekyll',
                    wc.strip_frontmatter(self.jekyll),
                    parsed=self.plaintext,
                    is_jekyll=True)
     self.assertEqual(
         result, {
             'counts': {
                 'characters_real': 198,
                 'characters_total': 268,
                 'file': 'jekyll',
                 'paragraphs': 1,
                 'type': 'jekyll',
                 'words': 46,
             }
         })