Skip to content

Commit

Permalink
test: pin pytest-xdist
Browse files Browse the repository at this point in the history
  • Loading branch information
DawoudSheraz committed Dec 28, 2023
1 parent 6cca2c9 commit da4700c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

import responses
from django.core.management import call_command
from django.test import TestCase
from django.test import TransactionTestCase

from course_discovery.apps.api.v1.tests.test_views.mixins import OAuth2Mixin
from course_discovery.apps.course_metadata.models import (
Course, CourseEntitlement, CourseRun, Degree, LevelType, Person, Program, Seat, Subject
)


class AddProvisioningDataCommandTests(TestCase, OAuth2Mixin):
class AddProvisioningDataCommandTests(TransactionTestCase, OAuth2Mixin):
"""
Test suite for add_provisioning_data management command.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,6 @@
class RefreshCourseMetadataCommandTests(OAuth2Mixin, TransactionTestCase):
def setUp(self):
super().setUp()
# ContentTypeManager uses a cache to speed up ContentType retrieval. This
# cache persists across tests. This is fine in the context of a regular
# TestCase which uses a transaction to reset the database between tests.
# However, it becomes a problem in subclasses of TransactionTestCase which
# truncate all tables to reset the database between tests. When tables are
# truncated, ContentType objects in the ContentTypeManager's cache become
# stale. Attempting to use these stale objects in tests such as the ones
# below, which create LogEntry objects as a side-effect of interacting with
# the admin, will result in IntegrityErrors on databases that check foreign
# key constraints (e.g., MySQL). Preemptively clearing the cache prevents
# stale ContentType objects from being used.
ContentType.objects.clear_cache()
self.partner = PartnerFactory()
partner = self.partner
self.pipeline = [
Expand Down
5 changes: 5 additions & 0 deletions requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,8 @@ selenium==4.12.0

# Open AI version 1.0.0 dropped support for openai.ChatCompletion which is currently in use in enterprise.
openai<=0.28.1

# Version 3.5.0 is causing some tests (learner_pathway models, test_add_provisioning_data, etc.) to fail
# all of a sudden. The v3.5.0 introduces some ordering changes in tests and that is causing an existing test(s)
# that is not cleaning up properly to cause other failures. Pinning the version to unblock requirements upgrade.
pytest-xdist < 3.5.0
6 changes: 4 additions & 2 deletions requirements/local.txt
Original file line number Diff line number Diff line change
Expand Up @@ -702,8 +702,10 @@ pytest-responses==0.5.1
# via -r requirements/test.in
pytest-split==0.8.1
# via -r requirements/local.in
pytest-xdist==3.5.0
# via -r requirements/test.in
pytest-xdist==3.4.0
# via
# -c requirements/constraints.txt
# -r requirements/test.in
python-dateutil==2.8.2
# via
# -r requirements/base.in
Expand Down

0 comments on commit da4700c

Please sign in to comment.