Добавил класс, отвечающий за удаление комментариев из входной строки

This commit is contained in:
Rustam Zaitov 2013-11-05 01:02:44 +04:00
parent b3f7ff1f7b
commit 5ce8eb0269
2 changed files with 24 additions and 1 deletions

View File

@ -2,5 +2,9 @@ class CommentRemover:
def processLine(self, line):
assert line is not None
newLine = line
index = line.find('#')
if index >= 0:
newLine = line[:index]
return newLine

View File

@ -0,0 +1,19 @@
import unittest
from Core.LineConveyor.CommentRemover import CommentRemover
class TestCommentRemover(unittest.TestCase):
def setUp(self):
self.commentRemover = CommentRemover()
def test_startsWithComment(self):
line = '# this line is comment'
newLine = self.commentRemover.processLine(line)
self.assertEqual('', newLine)
def test_containsComment(self):
line = 'this line contains # a comment'
newLine = self.commentRemover.processLine(line)
self.assertEqual('this line contains ', newLine)