-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from coalib.bears.LocalBear import LocalBear | ||
from coalib.results.RESULT_SEVERITY import RESULT_SEVERITY | ||
from coalib.results.Result import Result | ||
from coalib.misc.i18n import _ | ||
|
||
|
||
class LineCountBear(LocalBear): | ||
def run_bear(self, filename, file, *args): | ||
""" | ||
Counts the lines of each file. | ||
""" | ||
return [Result( | ||
self.__class__.__name__, | ||
_("This file has {count} lines.").format(count=len(file)), | ||
RESULT_SEVERITY.INFO | ||
)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from queue import Queue | ||
import sys | ||
|
||
sys.path.insert(0, ".") | ||
import unittest | ||
from coalib.settings.Section import Section | ||
from coalib.results.Result import Result, RESULT_SEVERITY | ||
from bears.tests.LocalBearTestHelper import LocalBearTestHelper | ||
from bears.misc.LineCountBear import LineCountBear, _ | ||
|
||
|
||
class SpaceConsistencyBearTest(LocalBearTestHelper): | ||
def setUp(self): | ||
self.uut = LineCountBear(Section("name"), Queue()) | ||
|
||
def test_run(self): | ||
self.assertLinesYieldResult( | ||
self.uut, | ||
["1", "2", "3"], | ||
Result("LineCountBear", | ||
_("This file has {count} lines.").format(count=3), | ||
RESULT_SEVERITY.INFO | ||
) | ||
) | ||
self.assertLinesYieldResult( | ||
self.uut, | ||
[], | ||
Result("LineCountBear", | ||
_("This file has {count} lines.").format(count=0), | ||
RESULT_SEVERITY.INFO) | ||
) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main(verbosity=2) |
9331194
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack