Skip to content

Commit

Permalink
(no-ticket) Skip some tests on Mac
Browse files Browse the repository at this point in the history
Change-Id: Ia3a52e6836246de55faa31454d184855df97e848
  • Loading branch information
accek committed May 31, 2018
1 parent d69657c commit 42e9f80
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
9 changes: 9 additions & 0 deletions oioioi/base/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import threading
from contextlib import contextmanager
from mock import patch
import sys

from django.db import connections, DEFAULT_DB_ALIAS
from django.utils import timezone
Expand All @@ -13,6 +14,7 @@
from django.utils.translation import ugettext_lazy as _
from django.template.loaders.cached import Loader as CachedLoader
import six.moves.urllib.parse
import pytest


# Based on: https://github.com/revsys/django-test-plus/blob/master/test_plus/test.py#L30
Expand Down Expand Up @@ -147,3 +149,10 @@ def assertNoneIn(self, elems, container, msg=None):
"""Checks that ``container`` doesn't contain any of ``elems``."""
for e in elems:
self.assertNotIn(e, container, msg)


def needs_linux(fn):
return pytest.mark.skip(sys.platform not in ('linux', 'linux2'),
reason="This test needs Linux")(fn)


4 changes: 3 additions & 1 deletion oioioi/problems/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
import six.moves.urllib.parse
from six.moves import range

from oioioi.base.tests import TestCase, check_not_accessible
from oioioi.base.tests import TestCase, check_not_accessible, \
needs_linux
from oioioi.contests.current_contest import ContestMode
from oioioi.contests.models import Contest, ProblemInstance, Round
from oioioi.filetracker.tests import TestStreamingMixin
Expand Down Expand Up @@ -571,6 +572,7 @@ def get_test_filename(name):
return os.path.join(os.path.dirname(__file__), '../sinolpack/files', name)


@needs_linux
class TestProblemsetUploading(TransactionTestCase, TestStreamingMixin):
fixtures = ['test_users', 'test_contest']

Expand Down
30 changes: 21 additions & 9 deletions oioioi/sinolpack/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import six.moves.urllib.parse
from six.moves import cStringIO as StringIO

from oioioi.base.tests import TestCase
from oioioi.base.tests import TestCase, needs_linux
from oioioi.contests.current_contest import ContestMode
from oioioi.contests.models import (Contest, ProblemInstance, Submission,
UserResultForContest)
Expand All @@ -34,6 +34,15 @@ def get_test_filename(name):
BOTH_CONFIGURATIONS = '%test_both_configurations'


def use_makefiles(fn):
return override_settings(USE_SINOLPACK_MAKEFILES=True)(
(fn))


def no_makefiles(fn):
return override_settings(USE_SINOLPACK_MAKEFILES=False)(fn)


# When a class inheriting from django.test.TestCase is decorated with
# enable_both_unpack_configurations, all its methods decorated with
# both_configurations will be run twice. Once in safe and once in unsafe unpack
Expand All @@ -46,10 +55,8 @@ def get_test_filename(name):
def enable_both_unpack_configurations(cls):
for name, fn in list(cls.__dict__.items()):
if getattr(fn, BOTH_CONFIGURATIONS, False):
setattr(cls, '%s_safe' % (name),
override_settings(USE_SINOLPACK_MAKEFILES=False)(fn))
setattr(cls, '%s_unsafe' % (name),
override_settings(USE_SINOLPACK_MAKEFILES=True)(fn))
setattr(cls, '%s_safe' % (name), no_makefiles(fn))
setattr(cls, '%s_unsafe' % (name), use_makefiles(fn))
delattr(cls, name)
return cls

Expand All @@ -59,10 +66,7 @@ def both_configurations(fn):
return fn


@enable_both_unpack_configurations
class TestSinolPackage(TestCase):
fixtures = ['test_users', 'test_contest']

class TestSinolPackageIdentify(TestCase):
def test_identify_zip(self):
filename = get_test_filename('test_simple_package.zip')
self.assert_(SinolPackageBackend().identify(filename))
Expand All @@ -71,6 +75,12 @@ def test_identify_tgz(self):
filename = get_test_filename('test_full_package.tgz')
self.assert_(SinolPackageBackend().identify(filename))


@enable_both_unpack_configurations
@needs_linux
class TestSinolPackage(TestCase):
fixtures = ['test_users', 'test_contest']

def test_title_in_config_yml(self):
filename = get_test_filename('test_simple_package.zip')
call_command('addproblem', filename)
Expand Down Expand Up @@ -396,6 +406,7 @@ def test_interactive_task(self):


@enable_both_unpack_configurations
@needs_linux
class TestSinolPackageInContest(TransactionTestCase, TestStreamingMixin):
fixtures = ['test_users', 'test_contest']

Expand Down Expand Up @@ -564,6 +575,7 @@ def test_judging(self):
self.assertEqual(urc.score, IntegerScore(34))


@needs_linux
class TestLimits(TestCase):
fixtures = ['test_users', 'test_contest']

Expand Down

0 comments on commit 42e9f80

Please sign in to comment.