| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d8e7c04 commit 900fb63
10 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -81,6 +81,22 @@ | |||
| 81 | 81 | AWS_CMD = None | |
| 82 | 82 | ||
| 83 | 83 | ||
| 84 | + def skip_if_windows(reason): | ||
| 85 | + """Decorator to skip tests that should not be run on windows. | ||
| 86 | + | ||
| 87 | + Example usage: | ||
| 88 | + | ||
| 89 | + @skip_if_windows("Not valid") | ||
| 90 | + def test_some_non_windows_stuff(self): | ||
| 91 | + self.assertEqual(...) | ||
| 92 | + | ||
| 93 | + """ | ||
| 94 | + def decorator(func): | ||
| 95 | + return unittest.skipIf( | ||
| 96 | + platform.system() not in ['Darwin', 'Linux'], reason)(func) | ||
| 97 | + return decorator | ||
| 98 | + | ||
| 99 | + | ||
| 84 | 100 | def create_clidriver(): | |
| 85 | 101 | driver = awscli.clidriver.create_clidriver() | |
| 86 | 102 | session = driver.session | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,6 +34,7 @@ | |||
| 34 | 34 | from nose.plugins.attrib import attr | |
| 35 | 35 | ||
| 36 | 36 | from awscli.testutils import unittest, get_stdout_encoding | |
| 37 | + from awscli.testutils import skip_if_windows | ||
| 37 | 38 | from awscli.testutils import aws as _aws | |
| 38 | 39 | from awscli.testutils import BaseS3CLICommand | |
| 39 | 40 | from tests.integration.customizations.s3 import create_bucket as _create_bucket | |
@@ -221,8 +222,7 @@ def test_cant_move_large_file_onto_itself(self): | |||
| 221 | 222 | ||
| 222 | 223 | ||
| 223 | 224 | class TestRm(BaseS3CLICommand): | |
| 224 | - @unittest.skipIf(platform.system() not in ['Darwin', 'Linux'], | ||
| 225 | - 'Newline in filename test not valid on windows.') | ||
| 225 | + @skip_if_windows('Newline in filename test not valid on windows.') | ||
| 226 | 226 | # Windows won't let you do this. You'll get: | |
| 227 | 227 | # [Errno 22] invalid mode ('w') or filename: | |
| 228 | 228 | # 'c:\\windows\\temp\\tmp0fv8uu\\foo\r.txt' | |
@@ -341,8 +341,7 @@ def test_download_large_file(self): | |||
| 341 | 341 | len(foo_contents.getvalue())) | |
| 342 | 342 | ||
| 343 | 343 | @attr('slow') | |
| 344 | - @unittest.skipIf(platform.system() not in ['Darwin', 'Linux'], | ||
| 345 | - 'SIGINT not supported on Windows.') | ||
| 344 | + @skip_if_windows('SIGINT not supported on Windows.') | ||
| 346 | 345 | def test_download_ctrl_c_does_not_hang(self): | |
| 347 | 346 | bucket_name = self.create_bucket() | |
| 348 | 347 | foo_contents = six.BytesIO(b'abcd' * (1024 * 1024 * 20)) | |
@@ -784,8 +783,7 @@ def test_no_exist(self): | |||
| 784 | 783 | self.assertIn('The user-provided path %s does not exist.' % | |
| 785 | 784 | filename, p.stderr) | |
| 786 | 785 | ||
| 787 | - @unittest.skipIf(platform.system() not in ['Darwin', 'Linux'], | ||
| 788 | - 'Read permissions tests only supported on mac/linux') | ||
| 786 | + @skip_if_windows('Read permissions tests only supported on mac/linux') | ||
| 789 | 787 | def test_no_read_access(self): | |
| 790 | 788 | if os.geteuid() == 0: | |
| 791 | 789 | self.skipTest('Cannot completely remove read access as root user.') | |
@@ -800,8 +798,7 @@ def test_no_read_access(self): | |||
| 800 | 798 | self.assertIn('warning: Skipping file %s. File/Directory is ' | |
| 801 | 799 | 'not readable.' % filename, p.stderr) | |
| 802 | 800 | ||
| 803 | - @unittest.skipIf(platform.system() not in ['Darwin', 'Linux'], | ||
| 804 | - 'Special files only supported on mac/linux') | ||
| 801 | + @skip_if_windows('Special files only supported on mac/linux') | ||
| 805 | 802 | def test_is_special_file(self): | |
| 806 | 803 | file_path = os.path.join(self.files.rootdir, 'foo') | |
| 807 | 804 | # Use socket for special file. | |
@@ -814,8 +811,7 @@ def test_is_special_file(self): | |||
| 814 | 811 | "socket." % file_path), p.stderr) | |
| 815 | 812 | ||
| 816 | 813 | ||
| 817 | - @unittest.skipIf(platform.system() not in ['Darwin', 'Linux'], | ||
| 818 | - 'Symlink tests only supported on mac/linux') | ||
| 814 | + @skip_if_windows('Symlink tests only supported on mac/linux') | ||
| 819 | 815 | class TestSymlinks(BaseS3CLICommand): | |
| 820 | 816 | """ | |
| 821 | 817 | This class test the ability to follow or not follow symlinks. | |
@@ -1203,8 +1199,7 @@ def test_dryrun_download_large_file(self): | |||
| 1203 | 1199 | "argument was not obeyed.") | |
| 1204 | 1200 | ||
| 1205 | 1201 | ||
| 1206 | - @unittest.skipIf(platform.system() not in ['Darwin', 'Linux'], | ||
| 1207 | - 'Memory tests only supported on mac/linux') | ||
| 1202 | + @skip_if_windows('Memory tests only supported on mac/linux') | ||
| 1208 | 1203 | class TestMemoryUtilization(BaseS3CLICommand): | |
| 1209 | 1204 | # These tests verify the memory utilization and growth are what we expect. | |
| 1210 | 1205 | def extra_setup(self): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,6 +20,7 @@ | |||
| 20 | 20 | import botocore.session | |
| 21 | 21 | from awscli.testutils import unittest, aws, BaseS3CLICommand | |
| 22 | 22 | from awscli.testutils import temporary_file | |
| 23 | + from awscli.testutils import skip_if_windows | ||
| 23 | 24 | from awscli.clidriver import create_clidriver | |
| 24 | 25 | ||
| 25 | 26 | ||
@@ -354,6 +355,7 @@ def test_error_msg_with_no_region_configured(self): | |||
| 354 | 355 | p = aws('ec2 describe-instances', env_vars=environ) | |
| 355 | 356 | self.assertIn('must specify a region', p.stderr) | |
| 356 | 357 | ||
| 358 | + @skip_if_windows('Ctrl-C not supported on windows.') | ||
| 357 | 359 | def test_ctrl_c_does_not_print_traceback(self): | |
| 358 | 360 | # Relying on the fact that this generally takes | |
| 359 | 361 | # more than 1 second to complete. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,6 +13,7 @@ | |||
| 13 | 13 | import os | |
| 14 | 14 | import platform | |
| 15 | 15 | from awscli.testutils import unittest, FileCreator, BaseAWSCommandParamsTest | |
| 16 | + from awscli.testutils import skip_if_windows | ||
| 16 | 17 | import stat | |
| 17 | 18 | import tempfile | |
| 18 | 19 | import shutil | |
@@ -29,8 +30,7 @@ | |||
| 29 | 30 | compare_files | |
| 30 | 31 | ||
| 31 | 32 | ||
| 32 | - @unittest.skipIf(platform.system() not in ['Darwin', 'Linux'], | ||
| 33 | - 'Special files only supported on mac/linux') | ||
| 33 | + @skip_if_windows('Special files only supported on mac/linux') | ||
| 34 | 34 | class TestIsSpecialFile(unittest.TestCase): | |
| 35 | 35 | def setUp(self): | |
| 36 | 36 | self.files = FileCreator() | |
@@ -158,8 +158,7 @@ def test_local_directory(self): | |||
| 158 | 158 | compare_files(self, result_list[i], ref_list[i]) | |
| 159 | 159 | ||
| 160 | 160 | ||
| 161 | - @unittest.skipIf(platform.system() not in ['Darwin', 'Linux'], | ||
| 162 | - 'Symlink tests only supported on mac/linux') | ||
| 161 | + @skip_if_windows('Symlink tests only supported on mac/linux') | ||
| 163 | 162 | class TestIgnoreFilesLocally(unittest.TestCase): | |
| 164 | 163 | """ | |
| 165 | 164 | This class tests the ability to ignore particular files. This includes | |
@@ -251,8 +250,7 @@ def test_no_read_access(self): | |||
| 251 | 250 | ("warning: Skipping file %s. File/Directory is " | |
| 252 | 251 | "not readable." % full_path)) | |
| 253 | 252 | ||
| 254 | - @unittest.skipIf(platform.system() not in ['Darwin', 'Linux'], | ||
| 255 | - 'Special files only supported on mac/linux') | ||
| 253 | + @skip_if_windows('Special files only supported on mac/linux') | ||
| 256 | 254 | def test_is_special_file_warning(self): | |
| 257 | 255 | file_gen = FileGenerator(self.client, '', False) | |
| 258 | 256 | file_path = os.path.join(self.files.rootdir, 'foo') | |
@@ -268,8 +266,7 @@ def test_is_special_file_warning(self): | |||
| 268 | 266 | "socket." % file_path)) | |
| 269 | 267 | ||
| 270 | 268 | ||
| 271 | - @unittest.skipIf(platform.system() not in ['Darwin', 'Linux'], | ||
| 272 | - 'Symlink tests only supported on mac/linux') | ||
| 269 | + @skip_if_windows('Symlink tests only supported on mac/linux') | ||
| 273 | 270 | class TestSymlinksIgnoreFiles(unittest.TestCase): | |
| 274 | 271 | """ | |
| 275 | 272 | This class tests the ability to list out the correct local files | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,7 +21,7 @@ | |||
| 21 | 21 | from botocore.exceptions import PartialCredentialsError | |
| 22 | 22 | from dateutil.tz import tzlocal | |
| 23 | 23 | ||
| 24 | - from awscli.testutils import unittest | ||
| 24 | + from awscli.testutils import unittest, skip_if_windows | ||
| 25 | 25 | from awscli.customizations import assumerole | |
| 26 | 26 | ||
| 27 | 27 | ||
@@ -400,8 +400,7 @@ def test_key_error_raised_when_cache_key_does_not_exist(self): | |||
| 400 | 400 | with self.assertRaises(KeyError): | |
| 401 | 401 | self.cache['foo'] | |
| 402 | 402 | ||
| 403 | - @unittest.skipIf(platform.system() not in ['Darwin', 'Linux'], | ||
| 404 | - 'File permissions tests not supported on Windows.') | ||
| 403 | + @skip_if_windows('File permissions tests not supported on Windows.') | ||
| 405 | 404 | def test_permissions_for_file_restricted(self): | |
| 406 | 405 | self.cache['mykey'] = {'foo': 'bar'} | |
| 407 | 406 | filename = os.path.join(self.tempdir, 'mykey.json') | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,7 +21,7 @@ | |||
| 21 | 21 | from six import StringIO | |
| 22 | 22 | ||
| 23 | 23 | from awscli.customizations import configure | |
| 24 | - from awscli.testutils import unittest | ||
| 24 | + from awscli.testutils import unittest, skip_if_windows | ||
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | 27 | class PrecannedPrompter(object): | |
@@ -419,8 +419,7 @@ def test_config_file_does_not_exist(self): | |||
| 419 | 419 | new_contents = f.read() | |
| 420 | 420 | self.assertEqual(new_contents, '[default]\nfoo = value\n') | |
| 421 | 421 | ||
| 422 | - @unittest.skipIf(sys.platform.lower().startswith('win'), | ||
| 423 | - "Test not valid on windows.") | ||
| 422 | + @skip_if_windows("Test not valid on windows.") | ||
| 424 | 423 | def test_permissions_on_new_file(self): | |
| 425 | 424 | self.writer.update_config({'foo': 'value'}, self.config_filename) | |
| 426 | 425 | with open(self.config_filename, 'r') as f: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,6 +18,7 @@ | |||
| 18 | 18 | from awscli.formatter import JSONFormatter | |
| 19 | 19 | ||
| 20 | 20 | from awscli.testutils import BaseAWSCommandParamsTest, unittest | |
| 21 | + from awscli.testutils import skip_if_windows | ||
| 21 | 22 | from awscli.compat import get_stdout_text_writer | |
| 22 | 23 | ||
| 23 | 24 | ||
@@ -101,8 +102,7 @@ def test_unknown_output_type_from_env_var(self): | |||
| 101 | 102 | self.environ['AWS_DEFAULT_OUTPUT'] = 'bad-output-type' | |
| 102 | 103 | self.run_cmd('iam list-users', expected_rc=255) | |
| 103 | 104 | ||
| 104 | - @unittest.skipIf(platform.system() not in ['Darwin', 'Linux'], | ||
| 105 | - 'Encoding tests only supported on mac/linux') | ||
| 105 | + @skip_if_windows('Encoding tests only supported on mac/linux') | ||
| 106 | 106 | def test_json_prints_unicode_chars(self): | |
| 107 | 107 | self.parsed_response['Users'][1]['UserId'] = u'\u2713' | |
| 108 | 108 | output = self.run_cmd('iam list-users', expected_rc=0)[0] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,7 +10,7 @@ | |||
| 10 | 10 | # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF | |
| 11 | 11 | # ANY KIND, either express or implied. See the License for the specific | |
| 12 | 12 | # language governing permissions and limitations under the License. | |
| 13 | - from awscli.testutils import unittest, FileCreator | ||
| 13 | + from awscli.testutils import unittest, skip_if_windows, FileCreator | ||
| 14 | 14 | import signal | |
| 15 | 15 | import platform | |
| 16 | 16 | import json | |
@@ -92,7 +92,7 @@ def test_pager_with_args(self): | |||
| 92 | 92 | self.assertEqual(self.renderer.get_pager_cmdline(), | |
| 93 | 93 | pager_cmd.split()) | |
| 94 | 94 | ||
| 95 | - @unittest.skipIf(sys.platform.startswith('win'), "requires posix system") | ||
| 95 | + @skip_if_windows('Requires posix system.') | ||
| 96 | 96 | def test_no_groff_exists(self): | |
| 97 | 97 | renderer = FakePosixHelpRenderer() | |
| 98 | 98 | renderer.exists_on_path['groff'] = False | |
@@ -119,8 +119,7 @@ def test_can_page_output_on_windows(self): | |||
| 119 | 119 | renderer.render('foo') | |
| 120 | 120 | self.assertEqual(renderer.popen_calls[-1][0], (['more'],)) | |
| 121 | 121 | ||
| 122 | - @unittest.skipIf(platform.system() not in ['Darwin', 'Linux'], | ||
| 123 | - "Ctrl-C not valid on windows.") | ||
| 122 | + @skip_if_windows("Ctrl-C not valid on windows.") | ||
| 124 | 123 | def test_can_handle_ctrl_c(self): | |
| 125 | 124 | class CtrlCRenderer(FakePosixHelpRenderer): | |
| 126 | 125 | def _popen(self, *args, **kwargs): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,6 +15,7 @@ | |||
| 15 | 15 | import mock | |
| 16 | 16 | from awscli.compat import six | |
| 17 | 17 | from awscli.testutils import unittest, FileCreator | |
| 18 | + from awscli.testutils import skip_if_windows | ||
| 18 | 19 | ||
| 19 | 20 | from awscli.paramfile import get_paramfile, ResourceLoadingError | |
| 20 | 21 | ||
@@ -42,9 +43,8 @@ def test_binary_file(self): | |||
| 42 | 43 | self.assertEqual(data, b'This is a test') | |
| 43 | 44 | self.assertIsInstance(data, six.binary_type) | |
| 44 | 45 | ||
| 45 | - @unittest.skipIf(platform.system() not in ['Darwin', 'Linux'], | ||
| 46 | - 'Binary content error only occurs on ' | ||
| 47 | - 'non-Windows platforms.') | ||
| 46 | + @skip_if_windows('Binary content error only occurs ' | ||
| 47 | + 'on non-Windows platforms.') | ||
| 48 | 48 | def test_cannot_load_text_file(self): | |
| 49 | 49 | contents = b'\xbfX\xac\xbe' | |
| 50 | 50 | filename = self.files.create_file('foo', contents, mode='wb') | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,7 +14,7 @@ | |||
| 14 | 14 | import platform | |
| 15 | 15 | import os | |
| 16 | 16 | ||
| 17 | - from awscli.testutils import unittest | ||
| 17 | + from awscli.testutils import unittest, skip_if_windows | ||
| 18 | 18 | from awscli.utils import split_on_commas, ignore_ctrl_c | |
| 19 | 19 | ||
| 20 | 20 | ||
@@ -91,8 +91,7 @@ def test_end_bracket_in_value(self): | |||
| 91 | 91 | ['foo', 'bar=foo,*[biz]*,baz']) | |
| 92 | 92 | ||
| 93 | 93 | ||
| 94 | - @unittest.skipIf(platform.system() not in ['Darwin', 'Linux'], | ||
| 95 | - "Ctrl-C not valid on windows.") | ||
| 94 | + @skip_if_windows("Ctrl-C not supported on windows.") | ||
| 96 | 95 | class TestIgnoreCtrlC(unittest.TestCase): | |
| 97 | 96 | def test_ctrl_c_is_ignored(self): | |
| 98 | 97 | with ignore_ctrl_c(): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments