Skip to content

Commit

Permalink
Harmonized Windows checks in tests to a single style.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdufresne authored and carltongibson committed Nov 6, 2019
1 parent e3c2fae commit 39791c8
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion tests/admin_filters/tests.py
Expand Up @@ -460,7 +460,7 @@ def test_datefieldlistfilter(self):
self.assertEqual(choice['query_string'], '?date_registered__isnull=False')

@unittest.skipIf(
sys.platform.startswith('win'),
sys.platform == 'win32',
"Windows doesn't support setting a timezone that differs from the "
"system timezone."
)
Expand Down
2 changes: 1 addition & 1 deletion tests/asgi/tests.py
Expand Up @@ -78,7 +78,7 @@ async def test_file_response(self):
set(response_start['headers']),
{
(b'Content-Length', str(len(test_file_contents)).encode('ascii')),
(b'Content-Type', b'text/plain' if sys.platform.startswith('win') else b'text/x-python'),
(b'Content-Type', b'text/plain' if sys.platform == 'win32' else b'text/x-python'),
(b'Content-Disposition', b'inline; filename="urls.py"'),
},
)
Expand Down
4 changes: 2 additions & 2 deletions tests/file_storage/tests.py
Expand Up @@ -771,7 +771,7 @@ def test_file_truncation(self):
o.delete()

@unittest.skipIf(
sys.platform.startswith('win'),
sys.platform == 'win32',
"Windows supports at most 260 characters in a path.",
)
def test_extended_length_storage(self):
Expand Down Expand Up @@ -897,7 +897,7 @@ def test_race_condition(self):
self.assertRegex(files[1], 'conflict_%s' % FILE_SUFFIX_REGEX)


@unittest.skipIf(sys.platform.startswith('win'), "Windows only partially supports umasks and chmod.")
@unittest.skipIf(sys.platform == 'win32', "Windows only partially supports umasks and chmod.")
class FileStoragePermissions(unittest.TestCase):
def setUp(self):
self.umask = 0o027
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/tests.py
Expand Up @@ -376,7 +376,7 @@ def test_dumpdata_with_excludes(self):
with self.assertRaisesMessage(management.CommandError, "Unknown model: fixtures.FooModel"):
self._dumpdata_assert(['fixtures', 'sites'], '', exclude_list=['fixtures.FooModel'])

@unittest.skipIf(sys.platform.startswith('win'), "Windows doesn't support '?' in filenames.")
@unittest.skipIf(sys.platform == 'win32', "Windows doesn't support '?' in filenames.")
def test_load_fixture_with_special_characters(self):
management.call_command('loaddata', 'fixture_with[special]chars', verbosity=0)
self.assertQuerysetEqual(Article.objects.all(), ['<Article: How To Deal With Special Characters>'])
Expand Down
2 changes: 1 addition & 1 deletion tests/model_fields/test_filefield.py
Expand Up @@ -72,7 +72,7 @@ def test_unique_when_same_filename(self):
with self.assertRaises(IntegrityError):
Document.objects.create(myfile='something.txt')

@unittest.skipIf(sys.platform.startswith('win'), "Windows doesn't support moving open files.")
@unittest.skipIf(sys.platform == 'win32', "Windows doesn't support moving open files.")
# The file's source and destination must be on the same filesystem.
@override_settings(MEDIA_ROOT=temp.gettempdir())
def test_move_temporary_file(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/staticfiles_tests/test_storage.py
Expand Up @@ -420,7 +420,7 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)


@unittest.skipIf(sys.platform.startswith('win'), "Windows only partially supports chmod.")
@unittest.skipIf(sys.platform == 'win32', "Windows only partially supports chmod.")
class TestStaticFilePermissions(CollectionTestCase):

command_params = {
Expand Down
2 changes: 1 addition & 1 deletion tests/template_tests/test_loaders.py
Expand Up @@ -196,7 +196,7 @@ def test_permissions_error(self):

def test_notafile_error(self):
# Windows raises PermissionError when trying to open a directory.
with self.assertRaises(PermissionError if sys.platform.startswith('win') else IsADirectoryError):
with self.assertRaises(PermissionError if sys.platform == 'win32' else IsADirectoryError):
self.engine.get_template('first')


Expand Down
4 changes: 2 additions & 2 deletions tests/timezones/tests.py
Expand Up @@ -969,7 +969,7 @@ def test_timezone_templatetag_invalid_argument(self):
with self.assertRaises(pytz.UnknownTimeZoneError):
Template("{% load tz %}{% timezone tz %}{% endtimezone %}").render(Context({'tz': 'foobar'}))

@skipIf(sys.platform.startswith('win'), "Windows uses non-standard time zone names")
@skipIf(sys.platform == 'win32', "Windows uses non-standard time zone names")
def test_get_current_timezone_templatetag(self):
"""
Test the {% get_current_timezone %} templatetag.
Expand Down Expand Up @@ -1009,7 +1009,7 @@ def test_get_current_timezone_templatetag_invalid_argument(self):
with self.assertRaisesMessage(TemplateSyntaxError, msg):
Template("{% load tz %}{% get_current_timezone %}").render()

@skipIf(sys.platform.startswith('win'), "Windows uses non-standard time zone names")
@skipIf(sys.platform == 'win32', "Windows uses non-standard time zone names")
def test_tz_template_context_processor(self):
"""
Test the django.template.context_processors.tz template context processor.
Expand Down

0 comments on commit 39791c8

Please sign in to comment.