| OLD | NEW |
| 1 # This file is part of the Adblock Plus web scripts, | 1 # This file is part of the Adblock Plus web scripts, |
| 2 # Copyright (C) 2006-present eyeo GmbH | 2 # Copyright (C) 2006-present eyeo GmbH |
| 3 # | 3 # |
| 4 # Adblock Plus is free software: you can redistribute it and/or modify | 4 # Adblock Plus is free software: you can redistribute it and/or modify |
| 5 # it under the terms of the GNU General Public License version 3 as | 5 # it under the terms of the GNU General Public License version 3 as |
| 6 # published by the Free Software Foundation. | 6 # published by the Free Software Foundation. |
| 7 # | 7 # |
| 8 # Adblock Plus is distributed in the hope that it will be useful, | 8 # Adblock Plus is distributed in the hope that it will be useful, |
| 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 del os.environ[env_var] | 75 del os.environ[env_var] |
| 76 | 76 |
| 77 | 77 |
| 78 def test_sanitize_project_name_characters(): | 78 def test_sanitize_project_name_characters(): |
| 79 """Test if invalid name characters are replaced as expected.""" | 79 """Test if invalid name characters are replaced as expected.""" |
| 80 test_in = '{0}{1}{0}'.format( | 80 test_in = '{0}{1}{0}'.format( |
| 81 'test', ''.join(const.ProjectName.INVALID_CHARS), | 81 'test', ''.join(const.ProjectName.INVALID_CHARS), |
| 82 ) | 82 ) |
| 83 exp_out = '{0}{1}{0}'.format( | 83 exp_out = '{0}{1}{0}'.format( |
| 84 'test', | 84 'test', |
| 85 const.ProjectName.NAME_WILDCARD * | 85 const.ProjectName.NAME_WILDCARD * len(const.ProjectName.INVALID_CHARS), |
| 86 len(const.ProjectName.INVALID_CHARS), | |
| 87 ) | 86 ) |
| 88 | 87 |
| 89 assert exp_out == utils.sanitize_project_name(test_in) | 88 assert exp_out == utils.sanitize_project_name(test_in) |
| 90 | 89 |
| 91 | 90 |
| 92 def test_sanitize_project_name_length(): | 91 def test_sanitize_project_name_length(): |
| 93 """Test if names that are too long are truncated as expected.""" | 92 """Test if names that are too long are truncated as expected.""" |
| 94 test_in = 'a' * (const.ProjectName.MAX_LENGTH + 10) | 93 test_in = 'a' * (const.ProjectName.MAX_LENGTH + 10) |
| 95 exp_out = 'a' * const.ProjectName.MAX_LENGTH | 94 exp_out = 'a' * const.ProjectName.MAX_LENGTH |
| 96 | 95 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 221 |
| 223 assert toydir.join(path).read('rb') == data | 222 assert toydir.join(path).read('rb') == data |
| 224 | 223 |
| 225 | 224 |
| 226 def test_extract_unicode_strings(temp_site): | 225 def test_extract_unicode_strings(temp_site): |
| 227 """Test correct extraction of unicode strings for translation.""" | 226 """Test correct extraction of unicode strings for translation.""" |
| 228 with FileSource(temp_site) as fs: | 227 with FileSource(temp_site) as fs: |
| 229 strings = utils.extract_strings(fs) | 228 strings = utils.extract_strings(fs) |
| 230 | 229 |
| 231 assert '\u0376' in strings['translate-unicode']['simple']['message'] | 230 assert '\u0376' in strings['translate-unicode']['simple']['message'] |
| OLD | NEW |