File: FileContainsRE.test

package info (click to toggle)
atheist 0.20110402-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 1,332 kB
  • ctags: 902
  • sloc: python: 4,764; xml: 626; makefile: 113; cpp: 54; ansic: 5; sh: 5
file content (33 lines) | stat: -rw-r--r-- 880 bytes parent folder | download | duplicates (3)
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)