1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
# -*- coding:utf-8; tab-width:4; mode:python -*-
import re
import unittest
from atheist.plugins.FileContainsRE import FileContainsRE
class Test_FileContainsRE_check(unittest.TestCase):
def setUp(self):
self.sut = FileContainsRE.check
def test_2_ocurrences(self):
self.assertEquals(2, self.sut("hello", "rehellopojahellofai asd"))
def test_unbalanced_parenthesis(self):
try:
self.sut("(he", "hello")
except re.error:
return
self.fail()
def test_escaped_parenthesis(self):
self.assertEquals(1, self.sut("\( \w+", "( hello"))
def test_real_life_example(self):
self.assertEquals(1, self.sut(
"pre: Not \(FileExists '/tmp/\w+-\w+/([0-9]+)/T1.out'",
"pre: Not (FileExists '/tmp/atheist-david/10243/T1.out'"))
UnitTestCase(Test_FileContainsRE_check)
|