From 5be73461dd673ed59ac499bc54da71c9b5066666 Mon Sep 17 00:00:00 2001 From: pombredanne Date: Mon, 12 Oct 2015 16:44:30 +0200 Subject: [PATCH] Fixed #223 tests * now dealing with paths bigger than Win32 can support alright --- about_code_tool/tests/test_about.py | 31 +++++++++++------- about_code_tool/tests/test_genattrib.py | 2 +- .../testdata/{ => longpath}/longpath.zip | Bin .../longpath1/non-supported_date_format.ABOUT | 4 --- 4 files changed, 21 insertions(+), 16 deletions(-) rename about_code_tool/tests/testdata/{ => longpath}/longpath.zip (100%) delete mode 100644 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 diff --git a/about_code_tool/tests/test_about.py b/about_code_tool/tests/test_about.py index ecc3c6d7..4f810ee2 100644 --- a/about_code_tool/tests/test_about.py +++ b/about_code_tool/tests/test_about.py @@ -43,11 +43,14 @@ from about_code_tool.util import posix_path from about_code_tool.tests.tstutil import get_temp_file +from about_code_tool.util import extract_zip TESTDATA_DIR = join(abspath(dirname(__file__)), 'testdata') class CollectorTest(unittest.TestCase): + maxDiff = None + def test_return_path_is_not_abspath_and_contains_subdirs_on_file(self): # Using a relative path for the purpose of this test 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): result = Collector.collect(test_file) self.assertEqual(expected, result) - def test_collect_can_collect_a_long_directory_tree(self): + def test_collect_can_collect_a_directory_tree_with_long_and_deep_paths(self): + test_zip = 'about_code_tool/tests/testdata/longpath/longpath.zip' + test_dir = extract_zip(test_zip) + + longpath = 'longpath1/' * 28 - test_dir = 'about_code_tool/tests/testdata/longpath/' + longpath - if on_windows: - # For some reasons, the os.path.abspath doesn't work if I have long - # path in the parameter. Therefore, I just append to long path - # after the os.path.abspath() - expected = [posix_path(UNC_PREFIX + os.path.abspath('about_code_tool') + '/tests/testdata/longpath/' + longpath + '/non-supported_date_format.ABOUT')] - else: - expected = [os.path.abspath(('about_code_tool/tests/testdata/longpath/' + longpath + 'non-supported_date_format.ABOUT'))] + expected = 'longpath/' + longpath + 'non-supported_date_format.ABOUT' - result = Collector.collect(test_dir) - self.assertEqual(sorted(expected), sorted(result)) + result = Collector.collect(test_dir)[0] + def rel_path(pth): + p = posix_path(pth) + return p.partition('/longpath/')[2] + print() + print(result) + print(rel_path(result)) + self.assertEqual(expected, rel_path(result)) def test_collector_errors_encapsulation(self): test_file = 'about_code_tool/tests/testdata/DateTest' @@ -149,7 +155,10 @@ def test_collector_warnings_encapsulation(self): # No warning is thrown as all fields from ABOUT files are accepted. self.assertEqual(0, len(collector.warnings)) + class ParserTest(unittest.TestCase): + maxDiff = None + def test_valid_chars_in_field_name(self): name = string.digits + string.ascii_letters + '_' line = string.digits + string.ascii_letters + '_' diff --git a/about_code_tool/tests/test_genattrib.py b/about_code_tool/tests/test_genattrib.py index 99b4ab5f..8ff39003 100644 --- a/about_code_tool/tests/test_genattrib.py +++ b/about_code_tool/tests/test_genattrib.py @@ -181,7 +181,7 @@ def test_genattrib_zip_with_filter(self): self.assertFalse(ex in result, ex) def test_extract_deep_zip(self): - test_zip = 'about_code_tool/tests/testdata/longpath.zip' + test_zip = 'about_code_tool/tests/testdata/longpath/longpath.zip' extracted = genattrib.extract_zip(test_zip) unc_extracted = add_unc(extracted) all_files = set() diff --git a/about_code_tool/tests/testdata/longpath.zip b/about_code_tool/tests/testdata/longpath/longpath.zip similarity index 100% rename from about_code_tool/tests/testdata/longpath.zip rename to about_code_tool/tests/testdata/longpath/longpath.zip diff --git a/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 b/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 deleted file mode 100644 index 11211ca2..00000000 --- a/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 +++ /dev/null @@ -1,4 +0,0 @@ -name: distribute -version: 1.1 -about_resource: distribute_setup.py -date:01/08/2013 \ No newline at end of file