comparison tests/test_fetch_command_regexes.py @ 16:48a44546c12f

Add a basic system for running the hgsubversion tests (although not the svnwrap ones) without requiring Nose. Nose is still the recommended way to run the tests. Also added some tests for pushing.
author Augie Fackler <durin42@gmail.com>
date Tue, 07 Oct 2008 22:13:14 -0500
parents e60bd31f58a7
children 99f8e4b535e9
comparison
equal deleted inserted replaced
15:db32dee803a8 16:48a44546c12f
1 import fetch_command 1 import fetch_command
2 import unittest
2 3
3 two_empties = """Index: __init__.py 4 two_empties = """Index: __init__.py
4 =================================================================== 5 ===================================================================
5 Index: bar/__init__.py 6 Index: bar/__init__.py
6 =================================================================== 7 ===================================================================
12 + 13 +
13 +blah blah blah, I'm a fake patch 14 +blah blah blah, I'm a fake patch
14 \ No newline at end of file 15 \ No newline at end of file
15 """ 16 """
16 17
17 def test_empty_file_re():
18 matches = fetch_command.empty_file_patch_wont_make_re.findall(two_empties)
19 assert sorted(matches) == ['__init__.py', 'bar/__init__.py']
20
21 def test_any_matches_just_one():
22 pat = '''Index: trunk/django/contrib/admin/urls/__init__.py
23 ===================================================================
24 '''
25 matches = fetch_command.any_file_re.findall(pat)
26 assert len(matches) == 1
27
28 def test_any_file_re():
29 matches = fetch_command.any_file_re.findall(two_empties)
30 assert sorted(matches) == ['__init__.py', 'bar/__init__.py',
31 'bar/test_muhaha.py']
32 binary_delta = """Index: trunk/functional_tests/doc_tests/test_doctest_fixtures/doctest_fixtures_fixtures.pyc 18 binary_delta = """Index: trunk/functional_tests/doc_tests/test_doctest_fixtures/doctest_fixtures_fixtures.pyc
33 =================================================================== 19 ===================================================================
34 Cannot display: file marked as a binary type. 20 Cannot display: file marked as a binary type.
35 svn:mime-type = application/octet-stream 21 svn:mime-type = application/octet-stream
36 22
40 + application/octet-stream 26 + application/octet-stream
41 27
42 Index: trunk/functional_tests/doc_tests/test_doctest_fixtures/doctest_fixtures.rst 28 Index: trunk/functional_tests/doc_tests/test_doctest_fixtures/doctest_fixtures.rst
43 =================================================================== 29 ===================================================================
44 """ 30 """
45 def test_binary_file_re(): 31
46 matches = fetch_command.binary_file_re.findall(binary_delta) 32 class RegexTests(unittest.TestCase):
47 print matches 33 def test_empty_file_re(self):
48 assert matches == ['trunk/functional_tests/doc_tests/test_doctest_fixtures/doctest_fixtures_fixtures.pyc'] 34 matches = fetch_command.empty_file_patch_wont_make_re.findall(two_empties)
35 assert sorted(matches) == ['__init__.py', 'bar/__init__.py']
36
37 def test_any_matches_just_one(self):
38 pat = '''Index: trunk/django/contrib/admin/urls/__init__.py
39 ===================================================================
40 '''
41 matches = fetch_command.any_file_re.findall(pat)
42 assert len(matches) == 1
43
44 def test_any_file_re(self):
45 matches = fetch_command.any_file_re.findall(two_empties)
46 assert sorted(matches) == ['__init__.py', 'bar/__init__.py',
47 'bar/test_muhaha.py']
48
49 def test_binary_file_re(self):
50 matches = fetch_command.binary_file_re.findall(binary_delta)
51 assert matches == ['trunk/functional_tests/doc_tests/test_doctest_fixtures/doctest_fixtures_fixtures.pyc']
52
53 def suite():
54 return unittest.TestLoader().loadTestsFromTestCase(RegexTests)