44
55from cycode .cli .files_collector .walk_ignore import (
66 _collect_top_level_ignore_files ,
7- _get_global_ignore_patterns ,
87 _walk_to_top ,
98 walk_ignore ,
109)
@@ -52,11 +51,9 @@ def _create_mocked_file_structure(fs: 'FakeFilesystem') -> None:
5251 fs .create_dir ('/home/user/project/.git' )
5352 fs .create_file ('/home/user/project/.git/HEAD' )
5453
55- fs .create_file ('/home/user/project/.gitignore' , contents = '*.pyc' )
54+ fs .create_file ('/home/user/project/.gitignore' , contents = '*.pyc\n *.log ' )
5655 fs .create_file ('/home/user/project/ignored.pyc' )
5756 fs .create_file ('/home/user/project/presented.txt' )
58-
59- fs .create_file ('/home/user/project/.cycodeignore' , contents = '*.log' )
6057 fs .create_file ('/home/user/project/ignored2.log' )
6158 fs .create_file ('/home/user/project/ignored2.pyc' )
6259 fs .create_file ('/home/user/project/presented2.txt' )
@@ -75,45 +72,27 @@ def test_collect_top_level_ignore_files(fs: 'FakeFilesystem') -> None:
7572 # Test with path inside the project
7673 path = normpath ('/home/user/project/subproject' )
7774 ignore_files = _collect_top_level_ignore_files (path )
78-
79- assert len (ignore_files ) == 3
75+ assert len (ignore_files ) == 2
8076 assert normpath ('/home/user/project/subproject/.gitignore' ) in ignore_files
8177 assert normpath ('/home/user/project/.gitignore' ) in ignore_files
82- assert normpath ('/home/user/project/.cycodeignore' ) in ignore_files
83-
84- # Test with a path that does not have any ignore files
85- fs .remove ('/home/user/project/.gitignore' )
86- path = normpath ('/home/user' )
87- ignore_files = _collect_top_level_ignore_files (path )
88-
89- assert len (ignore_files ) == 0
9078
9179 # Test with path at the top level with no ignore files
9280 path = normpath ('/home/user/.git' )
9381 ignore_files = _collect_top_level_ignore_files (path )
94-
9582 assert len (ignore_files ) == 0
9683
9784 # Test with path at the top level with a .gitignore
9885 path = normpath ('/home/user/project' )
9986 ignore_files = _collect_top_level_ignore_files (path )
100-
10187 assert len (ignore_files ) == 1
102- assert normpath ('/home/user/project/.cycodeignore' ) in ignore_files
103-
104-
105- def test_get_global_ignore_patterns (fs : 'FakeFilesystem' ) -> None :
106- _create_mocked_file_structure (fs )
107- ignore_patterns = _get_global_ignore_patterns ('/home/user/project/subproject' )
88+ assert normpath ('/home/user/project/.gitignore' ) in ignore_files
10889
109- assert len (ignore_patterns ) == 5
110- # default global:
111- assert '**/.git' in ignore_patterns
112- assert '**/.cycode' in ignore_patterns
113- # additional:
114- assert '*.txt' in ignore_patterns
115- assert '*.pyc' in ignore_patterns
116- assert '*.log' in ignore_patterns
90+ # Test with a path that does not have any ignore files
91+ fs .remove ('/home/user/project/.gitignore' )
92+ path = normpath ('/home/user' )
93+ ignore_files = _collect_top_level_ignore_files (path )
94+ assert len (ignore_files ) == 0
95+ fs .create_file ('/home/user/project/.gitignore' , contents = '*.pyc\n *.log' )
11796
11897
11998def _collect_walk_ignore_files (path : str ) -> List [str ]:
@@ -131,7 +110,7 @@ def test_walk_ignore(fs: 'FakeFilesystem') -> None:
131110 path = normpath ('/home/user/project' )
132111 result = _collect_walk_ignore_files (path )
133112
134- assert len (result ) == 6
113+ assert len (result ) == 5
135114 # ignored globally by default:
136115 assert normpath ('/home/user/project/.git/HEAD' ) not in result
137116 assert normpath ('/home/user/project/.cycode/config.yaml' ) not in result
@@ -146,7 +125,6 @@ def test_walk_ignore(fs: 'FakeFilesystem') -> None:
146125 assert normpath ('/home/user/project/subproject/ignored.log' ) not in result
147126 # presented after both .gitignore and .cycodeignore:
148127 assert normpath ('/home/user/project/.gitignore' ) in result
149- assert normpath ('/home/user/project/.cycodeignore' ) in result
150128 assert normpath ('/home/user/project/subproject/.gitignore' ) in result
151129 assert normpath ('/home/user/project/presented.txt' ) in result
152130 assert normpath ('/home/user/project/presented2.txt' ) in result
0 commit comments