コード例 #1
0
 def test_parse_list(self):
     patterns = TagPattern.parse_list('tag+foo,tag-xxx')
     for pattern in patterns:
         self.assertTrue(pattern.match(self.column))
     patterns = TagPattern.parse_list('tag-foo,tag+xxx')
     for pattern in patterns:
         self.assertFalse(pattern.match(self.column))
コード例 #2
0
 def test_parse_list(self):
     patterns = TagPattern.parse_list('tag+foo,tag-xxx')
     for pattern in patterns:
         self.assertTrue(pattern.match(self.column))
     patterns = TagPattern.parse_list('tag-foo,tag+xxx')
     for pattern in patterns:
         self.assertFalse(pattern.match(self.column))
コード例 #3
0
    def test_absolute(self):
        # don't allow exclusions in an absolute pattern
        with self.assertRaises(ValueError):
            pattern = TagPattern.parse('#foo+a-b!')

        pattern = TagPattern.parse('#foo+a!')
        self.assertTrue(pattern.is_absolute)
        self.assertTrue(pattern.match(Column.parse('#foo+a')))
        self.assertFalse(pattern.match(Column.parse('#foo')))
        self.assertFalse(pattern.match(Column.parse('#foo+a+b')))
コード例 #4
0
    def test_absolute(self):
        # don't allow exclusions in an absolute pattern
        with self.assertRaises(ValueError):
            pattern = TagPattern.parse('#foo+a-b!')

        pattern = TagPattern.parse('#foo+a!')
        self.assertTrue(pattern.is_absolute)
        self.assertTrue(pattern.match(Column.parse('#foo+a')))
        self.assertFalse(pattern.match(Column.parse('#foo')))
        self.assertFalse(pattern.match(Column.parse('#foo+a+b')))
コード例 #5
0
    def test_parse(self):
        pattern = TagPattern.parse('#tag+foo-xxx')
        self.assertEqual(pattern.tag, '#tag')
        self.assertTrue('foo' in pattern.include_attributes)

        pattern = TagPattern.parse('tag+foo-xxx')
        self.assertEqual(pattern.tag, '#tag')

        pattern = TagPattern.parse('   tag +foo  -xxx  ')
        self.assertEqual(pattern.tag, '#tag')
        self.assertEqual({'foo'}, pattern.include_attributes)
        self.assertEqual({'xxx'}, pattern.exclude_attributes)
コード例 #6
0
    def test_attributes_wildcard(self):
        pattern = TagPattern.parse('*+foo')
        self.assertTrue(pattern.is_wildcard())
        self.assertTrue(pattern.match(self.column))

        pattern = TagPattern.parse('*-foo')
        self.assertTrue(pattern.is_wildcard())
        self.assertFalse(pattern.match(self.column))

        pattern = TagPattern.parse('*+xxx')
        self.assertTrue(pattern.is_wildcard())
        self.assertFalse(pattern.match(self.column))
コード例 #7
0
    def test_parse(self):
        pattern = TagPattern.parse('#tag+foo-xxx')
        self.assertEqual(pattern.tag, '#tag')
        self.assertTrue('foo' in pattern.include_attributes)

        pattern = TagPattern.parse('tag+foo-xxx')
        self.assertEqual(pattern.tag, '#tag')

        pattern = TagPattern.parse('   tag +foo  -xxx  ')
        self.assertEqual(pattern.tag, '#tag')
        self.assertEqual({'foo'}, pattern.include_attributes)
        self.assertEqual({'xxx'}, pattern.exclude_attributes)
コード例 #8
0
    def test_attributes_wildcard(self):
        pattern = TagPattern.parse('*+foo')
        self.assertTrue(pattern.is_wildcard())
        self.assertTrue(pattern.match(self.column))

        pattern = TagPattern.parse('*-foo')
        self.assertTrue(pattern.is_wildcard())
        self.assertFalse(pattern.match(self.column))

        pattern = TagPattern.parse('*+xxx')
        self.assertTrue(pattern.is_wildcard())
        self.assertFalse(pattern.match(self.column))
コード例 #9
0
 def test_wildcard_empty_column(self):
     pattern = TagPattern.parse('*')
     untagged_column = Column(header="Foo", column_number=1)
     self.assertFalse(pattern.match(untagged_column))
コード例 #10
0
 def test_simple_wildcard(self):
     pattern = TagPattern.parse('*')
     self.assertTrue(pattern.is_wildcard())
     self.assertTrue(pattern.match(self.column))
コード例 #11
0
 def test_caseinsensitive(self):
     pattern = TagPattern.parse('#Tag')
     self.assertTrue(pattern.match(self.column))
     pattern = TagPattern.parse('#tag+fOO')
     self.assertTrue(pattern.match(self.column))
コード例 #12
0
 def test_exclude(self):
     pattern = TagPattern('#tag', exclude_attributes=['xxx'])
     self.assertTrue(pattern.match(self.column))
     pattern = TagPattern('#tag', exclude_attributes=['foo'])
     self.assertFalse(pattern.match(self.column))
コード例 #13
0
 def test_simple(self):
     pattern = TagPattern('#tag')
     self.assertTrue(pattern.match(self.column))
     pattern = TagPattern('#tagx')
     self.assertFalse(pattern.match(self.column))
コード例 #14
0
 def test_simple(self):
     pattern = TagPattern('#tag')
     self.assertTrue(pattern.match(self.column))
     pattern = TagPattern('#tagx')
     self.assertFalse(pattern.match(self.column))
コード例 #15
0
 def test_exclude(self):
     pattern = TagPattern('#tag', exclude_attributes=['xxx'])
     self.assertTrue(pattern.match(self.column))
     pattern = TagPattern('#tag', exclude_attributes=['foo'])
     self.assertFalse(pattern.match(self.column))
コード例 #16
0
 def test_caseinsensitive(self):
     pattern = TagPattern.parse('#Tag')
     self.assertTrue(pattern.match(self.column))
     pattern = TagPattern.parse('#tag+fOO')
     self.assertTrue(pattern.match(self.column))
コード例 #17
0
 def test_simple_wildcard(self):
     pattern = TagPattern.parse('*')
     self.assertTrue(pattern.is_wildcard())
     self.assertTrue(pattern.match(self.column))
コード例 #18
0
 def test_wildcard_empty_column(self):
     pattern = TagPattern.parse('*')
     untagged_column = Column(header="Foo", column_number=1)
     self.assertFalse(pattern.match(untagged_column))
コード例 #19
0
 def test_caseinsensitive(self):
     pattern = TagPattern('#Tag')
     self.assertTrue(pattern.match(self.column))
     pattern = TagPattern('#tag', include_attributes=['fOO'])
     self.assertTrue(pattern.match(self.column))
コード例 #20
0
 def test_caseinsensitive(self):
     pattern = TagPattern('#Tag')
     self.assertTrue(pattern.match(self.column))
     pattern = TagPattern('#tag', include_attributes=['fOO'])
     self.assertTrue(pattern.match(self.column))