|
| 1 | +"""Tests for passive_voice.passive_voice check.""" |
| 2 | +from __future__ import absolute_import |
| 3 | +from proselint.checks.passive_voice import misc as chk |
| 4 | +from .check import Check |
| 5 | + |
| 6 | + |
| 7 | +class TestCheck(Check): |
| 8 | + """The test class for passive_voice.passive_voice.""" |
| 9 | + |
| 10 | + __test__ = True |
| 11 | + |
| 12 | + @property |
| 13 | + def this_check(self): |
| 14 | + """Boilerplate.""" |
| 15 | + return chk |
| 16 | + |
| 17 | + @property |
| 18 | + def test_smoke(self): |
| 19 | + """Basic smoke test for passive_voice.passive_voice.""" |
| 20 | + assert self.passes("This sentence is in the active voice.") |
| 21 | + assert self.passes("Harry ate six shrimp at dinner.") |
| 22 | + assert not self.passes("At dinner, six shrimp were eaten by Harry.") |
| 23 | + assert self.passes("Beautiful giraffes roam the savannah.") |
| 24 | + assert not self.passes("The savannah is roamed by beautiful giraffes.") |
| 25 | + assert self.passes("Sue changed the flat tire.") |
| 26 | + assert not self.passes("The flat tire was changed by sue.") |
| 27 | + assert self.passes("I ran the course in record time.") |
| 28 | + assert not self.passes("The course was run by me in record time.") |
| 29 | + assert self.passes("The choir really enjoys that piece.") |
| 30 | + assert not self.passes("That piece is really enjoyed by the choir.") |
| 31 | + assert self.passes("The two kings are signing the treaty.") |
| 32 | + assert not self.passes("The treaty is being signed by two kings.") |
| 33 | + |
| 34 | + def test_special_cases(self): |
| 35 | + """ |
| 36 | + Test for special cases in passive voice. |
| 37 | + https://multimedia-english.com/grammar/passive-voice-special-cases-52 |
| 38 | + """ |
| 39 | + assert self.passes(["I got fired yesterday.", |
| 40 | + "I was fired yesterday.", |
| 41 | + "If you get mugged, report it." |
| 42 | + "The balloon got filled with gas." |
| 43 | + "There was a fight, but nobody got hurt.", |
| 44 | + "Mary was given some flowers", |
| 45 | + "Some flowers were given to Mary", |
| 46 | + "I am thought to be a spy", |
| 47 | + "I was considered to be a tourist.", |
| 48 | + "I was made to do it.", |
| 49 | + "We were allowed to go."]) |
| 50 | + # Passive imperative, gramatically correct nonesense. |
| 51 | + assert not self.passes(["Let the television be turned off.", |
| 52 | + "Let your money be given to me."]) |
0 commit comments