def test_expansion_limt(self): """Test expansion limit.""" with self.assertRaises(_wcparse.PatternLimitException): _wcparse.compile('{1..11}', _wcparse.BRACE, 10) with self.assertRaises(_wcparse.PatternLimitException): _wcparse.compile('|'.join(['a'] * 11), _wcparse.SPLIT, 10) with self.assertRaises(_wcparse.PatternLimitException): _wcparse.compile( '{{{},{}}}'.format('|'.join(['a'] * 6), '|'.join(['a'] * 5)), _wcparse.SPLIT | _wcparse.BRACE, 10) with self.assertRaises(_wcparse.PatternLimitException): _wcparse.compile(['|'.join(['a'] * 10), '|'.join(['a'] * 5)], _wcparse.SPLIT | _wcparse.BRACE, 10)
def test_expansion_no_limit_compile(self): """Test no expansion limit compile.""" self.assertEqual(len(_wcparse.compile('{1..11}', _wcparse.BRACE, -1)), 11)
def test_compile_unique_optimization_okay(self): """Test that redundant patterns are reduced in compile.""" self.assertEqual( len(_wcparse.compile('|'.join(['a'] * 10), _wcparse.SPLIT, 10)), 1)
def test_compile_expansion_okay(self): """Test expansion is okay.""" self.assertEqual(len(_wcparse.compile('{1..10}', _wcparse.BRACE)), 10)
def test_bad_root_dir(self): """Test bad root directory.""" with self.assertRaises(TypeError): _wcparse.compile(['string'], _wcparse.PATHNAME | _wcparse.REALPATH, 0).match('string', b'rdir', None)