Skip to content

Commit 5be7346

Browse files
committed
Fixed #223 tests
* now dealing with paths bigger than Win32 can support alright
1 parent 436796c commit 5be7346

File tree

4 files changed

+21
-16
lines changed
  • about_code_tool/tests
    • testdata/longpath
      • longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1

4 files changed

+21
-16
lines changed

about_code_tool/tests/test_about.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,14 @@
4343
from about_code_tool.util import posix_path
4444

4545
from about_code_tool.tests.tstutil import get_temp_file
46+
from about_code_tool.util import extract_zip
4647

4748
TESTDATA_DIR = join(abspath(dirname(__file__)), 'testdata')
4849

4950

5051
class CollectorTest(unittest.TestCase):
52+
maxDiff = None
53+
5154
def test_return_path_is_not_abspath_and_contains_subdirs_on_file(self):
5255
# Using a relative path for the purpose of this test
5356
test_file = 'about_code_tool/tests/testdata/thirdparty/django_snippets_2413.ABOUT'
@@ -123,19 +126,22 @@ def test_collect_can_collect_a_single_file(self):
123126
result = Collector.collect(test_file)
124127
self.assertEqual(expected, result)
125128

126-
def test_collect_can_collect_a_long_directory_tree(self):
129+
def test_collect_can_collect_a_directory_tree_with_long_and_deep_paths(self):
130+
test_zip = 'about_code_tool/tests/testdata/longpath/longpath.zip'
131+
test_dir = extract_zip(test_zip)
132+
133+
127134
longpath = 'longpath1/' * 28
128-
test_dir = 'about_code_tool/tests/testdata/longpath/' + longpath
129-
if on_windows:
130-
# For some reasons, the os.path.abspath doesn't work if I have long
131-
# path in the parameter. Therefore, I just append to long path
132-
# after the os.path.abspath()
133-
expected = [posix_path(UNC_PREFIX + os.path.abspath('about_code_tool') + '/tests/testdata/longpath/' + longpath + '/non-supported_date_format.ABOUT')]
134-
else:
135-
expected = [os.path.abspath(('about_code_tool/tests/testdata/longpath/' + longpath + 'non-supported_date_format.ABOUT'))]
135+
expected = 'longpath/' + longpath + 'non-supported_date_format.ABOUT'
136136

137-
result = Collector.collect(test_dir)
138-
self.assertEqual(sorted(expected), sorted(result))
137+
result = Collector.collect(test_dir)[0]
138+
def rel_path(pth):
139+
p = posix_path(pth)
140+
return p.partition('/longpath/')[2]
141+
print()
142+
print(result)
143+
print(rel_path(result))
144+
self.assertEqual(expected, rel_path(result))
139145

140146
def test_collector_errors_encapsulation(self):
141147
test_file = 'about_code_tool/tests/testdata/DateTest'
@@ -149,7 +155,10 @@ def test_collector_warnings_encapsulation(self):
149155
# No warning is thrown as all fields from ABOUT files are accepted.
150156
self.assertEqual(0, len(collector.warnings))
151157

158+
152159
class ParserTest(unittest.TestCase):
160+
maxDiff = None
161+
153162
def test_valid_chars_in_field_name(self):
154163
name = string.digits + string.ascii_letters + '_'
155164
line = string.digits + string.ascii_letters + '_'

about_code_tool/tests/test_genattrib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def test_genattrib_zip_with_filter(self):
181181
self.assertFalse(ex in result, ex)
182182

183183
def test_extract_deep_zip(self):
184-
test_zip = 'about_code_tool/tests/testdata/longpath.zip'
184+
test_zip = 'about_code_tool/tests/testdata/longpath/longpath.zip'
185185
extracted = genattrib.extract_zip(test_zip)
186186
unc_extracted = add_unc(extracted)
187187
all_files = set()
File renamed without changes.

about_code_tool/tests/testdata/longpath/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/longpath1/non-supported_date_format.ABOUT

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)