def test_no_match_sequence_not_at_end(self): """Test REGEX_FILE_COUNTER no match: sequence must be before extention""" test_str = "hello_3.x_x.txt" matches = REGEX_FILE_COUNTER.findall(test_str) self.assertFalse(matches)
def test_no_match_missing_sequence(self): """Test REGEX_FILE_COUNTER no match: missing sequence""" test_str = "file.txt" matches = REGEX_FILE_COUNTER.search(test_str) self.assertFalse(matches)
def test_no_match_invalid_sequence(self): """Test REGEX_FILE_COUNTER no match: invalid sequence""" test_str = "file1.txt" matches = REGEX_FILE_COUNTER.search(test_str) self.assertFalse(matches)
def test_sequence_numeric_ext_with_underscore(self): """ Test REGEX_FILE_COUNTER numeric extention with underscore""" test_str = "hello_3._123" matches = REGEX_FILE_COUNTER.findall(test_str) self.assertEqual(len(matches), 1) self.assertEqual(matches, ['3',])
def test_no_match_invlaid_extention(self): """Test REGEX_FILE_COUNTER no match: invalid extention""" test_str = "_1." matches = REGEX_FILE_COUNTER.search(test_str) self.assertFalse(matches)
def test_sequence_repeated(self): """ Test REGEX_FILE_COUNTER repeated in sequence""" test_str = "hello_1._3.txt" matches = REGEX_FILE_COUNTER.findall(test_str) self.assertEqual(len(matches), 1) self.assertEqual(matches, ['3',])
def test_sequence_underscore_ext(self): """ Test REGEX_FILE_COUNTER extention with underscore""" test_str = "hello_3._txt" matches = REGEX_FILE_COUNTER.findall(test_str) self.assertEqual(len(matches), 1) self.assertEqual(matches, ['3',])
def test_sequence_simple(self): """ Test REGEX_FILE_COUNTER simplest valid sequence""" test_str = "_1.txt" matches = REGEX_FILE_COUNTER.search(test_str) self.assertTrue(matches) self.assertEqual(matches.group('i'), '1')
def test_valid_numeric_matches_four_digit(self): """ Test REGEX_FILE_COUNTER valid numeric match 4 digits""" test_str = "file_1024.txt" matches = REGEX_FILE_COUNTER.search(test_str) self.assertTrue(matches) self.assertEqual(matches.group('i'), '1024')
def test_valid_numeric_matches_three_digit(self): """ Test REGEX_FILE_COUNTER valid numeric match 3 digits""" test_str = "file_256.txt" matches = REGEX_FILE_COUNTER.search(test_str) self.assertTrue(matches) self.assertEqual(matches.group('i'), '256')
def test_valid_numeric_matches_single_digit(self): """ Test REGEX_FILE_COUNTER valid numeric match 1 digit""" test_str = "file_8.txt" matches = REGEX_FILE_COUNTER.search(test_str) self.assertTrue(matches) self.assertEqual(matches.group('i'), '8')
def test_valid_numeric_matches_zero(self): """ Test REGEX_FILE_COUNTER valid numeric match 0""" test_str = "file_0.txt" matches = REGEX_FILE_COUNTER.search(test_str) self.assertTrue(matches) self.assertEqual(matches.group('i'), '0')