Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions release-notes.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
scame-0.3.4 - 2017/09/07
========================

* Add a semantic newline checker.


scame-0.3.1 - 2017/06/14
========================

Expand Down
2 changes: 1 addition & 1 deletion scame/__version__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
Keeps the version of the project.
"""
VERSION = '0.3.1'
VERSION = '0.3.4'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this should be 0.4.0 as is add a new feature... 0.3.X is for bugfixes

59 changes: 17 additions & 42 deletions scame/tests/test_restructuredtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@
| verse, and adornment-free lists.


Newline test! No newline.
Newline test? No newline.
Newline test. No newline.
Newline test has newline.
Indeed.

Expand Down Expand Up @@ -350,29 +347,31 @@ def test_check_section_delimiter_bad_marker_length(self):
self.assertEqual(expect, self.reporter.messages)
self.assertEqual(1, self.reporter.call_count)

def test_semantic_newline_fullstop(self):
"""When a full stop is not the last character of the line, it is
def test_semantic_newline_alltests_true(self):
"""When a ., ?, or ! is not the last character of the line, it is
considered a semantic newline violation and an error is reported."""
content = (
'Sentence. New sentence\n'
'Sentence. \n'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test is wrong...as it will trigger the "trailing newspaces" checker

'Sentence! \n'
'Sentence? \n'
)
checker = ReStructuredTextChecker('bogus', content, self.reporter)
checker.check_semantic_newline()
expect = ['Newline not created after a sentence.']
checker._check_semantic_newline()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the call with underline?

expect = ['Check that a new sentence is created after a full stop, ! or ?.']

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the expected value is wrong. it should repot a tuple of line number and error message

self.assertEqual(expect, self.reporter.messages)
self.assertEqual(1, self.reporter.call_count)

def test_semantic_newline_fullstop_true(self):
"""When a full stop is the last character from the line and follows the
semantic newline rule, an error is not reported."""
def test_semantic_newline_fullstop(self):
"""When a full stop is not the last character of the line, it is
considered a semantic newline violation and an error is reported."""
content = (
'Sentence. \n'
'New sentence.'
'Sentence. New sentence\n'
)
checker = ReStructuredTextChecker('bogus', content, self.reporter)
checker.check_semantic_newline()
self.assertEqual([], self.reporter.messages)
self.assertEqual(0, self.reporter.call_count)
checker._check_semantic_newline()
expect = ['Newline not created after a sentence.']
self.assertEqual(expect, self.reporter.messages)
self.assertEqual(1, self.reporter.call_count)

def test_semantic_newline_questionmark(self):
"""When a question mark is not the last character of the line, it is
Expand All @@ -381,47 +380,23 @@ def test_semantic_newline_questionmark(self):
'Sentence? New sentence\n'
)
checker = ReStructuredTextChecker('bogus', content, self.reporter)
checker.check_semantic_newline()
checker._check_semantic_newline()
expect = [('Newline not created after a ? sentence.')]
self.assertEqual(expect, self.reporter.messages)
self.assertEqual(1, self.reporter.call_count)

def test_semantic_newline_questionmark_true(self):
"""When a question mark is the last character from the line and follows
semantic newline rule, an error is not reported."""
content = (
'Sentence? \n'
'New sentence\n'
)
checker = ReStructuredTextChecker('bogus', content, self.reporter)
checker.check_semantic_newline()
self.assertEqual([], self.reporter.messages)
self.assertEqual(0, self.reporter.call_count)

def test_semantic_newline_exclamationmark(self):
"""When an exclamation mark is not the last character of the line, it
is considered a semantic newline violation and an error is reported."""
content = (
'Sentence! New sentence\n'
)
checker = ReStructuredTextChecker('bogus', content, self.reporter)
checker.check_semantic_newline()
checker._check_semantic_newline()
expect = [('Newline not created after a ! sentence.')]
self.assertEqual(expect, self.reporter.messages)
self.assertEqual(1, self.reporter.call_count)

def test_semantic_newline_exclamationmark_true(self):
"""When an exclamation mark is the last character from the line and
follows the semantic newline rule, an error is not reported."""
content = (
'Sentence! \n'
'New sentence\n'
)
checker = ReStructuredTextChecker('bogus', content, self.reporter)
checker.check_semantic_newline()
self.assertEqual([], self.reporter.messages)
self.assertEqual(0, self.reporter.call_count)

def test_check_section_delimiter_bad_length_both_markers(self):
content = (
'---------\n'
Expand Down