Skip to content

Commit df6f649

Browse files
authored
PYTHON-2927 PYTHON-2937 Skip failing tests on PyPy (#753)
Cleanup test clients more eagerly.
1 parent a4ccfa5 commit df6f649

File tree

6 files changed

+22
-2
lines changed

6 files changed

+22
-2
lines changed

test/test_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,6 +1552,7 @@ def test_direct_connection(self):
15521552

15531553
@unittest.skipIf(sys.platform.startswith('java'),
15541554
'Jython does not support gc.get_objects')
1555+
@unittest.skipIf('PyPy' in sys.version, 'PYTHON-2927 fails often on PyPy')
15551556
def test_continuous_network_errors(self):
15561557
def server_description_count():
15571558
i = 0

test/test_pooling.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ class TestPoolMaxSize(_TestPoolingBase):
421421
def test_max_pool_size(self):
422422
max_pool_size = 4
423423
c = rs_or_single_client(maxPoolSize=max_pool_size)
424+
self.addCleanup(c.close)
424425
collection = c[DB].test
425426

426427
# Need one document.
@@ -456,6 +457,7 @@ def f():
456457

457458
def test_max_pool_size_none(self):
458459
c = rs_or_single_client(maxPoolSize=None)
460+
self.addCleanup(c.close)
459461
collection = c[DB].test
460462

461463
# Need one document.

test/test_read_write_concern_spec.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def test_omit_default_read_write_concern(self):
5252
listener = EventListener()
5353
# Client with default readConcern and writeConcern
5454
client = rs_or_single_client(event_listeners=[listener])
55+
self.addCleanup(client.close)
5556
collection = client.pymongo_test.collection
5657
# Prepare for tests of find() and aggregate().
5758
collection.insert_many([{} for _ in range(10)])
@@ -209,6 +210,7 @@ def test_error_includes_errInfo(self):
209210
def test_write_error_details_exposes_errinfo(self):
210211
listener = EventListener()
211212
client = rs_or_single_client(event_listeners=[listener])
213+
self.addCleanup(client.close)
212214
db = client.errinfotest
213215
self.addCleanup(client.drop_database, "errinfotest")
214216
validator = {"x": {"$type": "string"}}

test/test_retryable_writes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ def test_increment_transaction_id_without_sending_command(self):
573573
listener = OvertCommandListener()
574574
client = rs_or_single_client(
575575
retryWrites=True, event_listeners=[listener])
576+
self.addCleanup(client.close)
576577
topology = client._topology
577578
select_server = topology.select_server
578579

test/test_ssl.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ def test_mongodb_x509_auth(self):
500500
ssl=True,
501501
tlsAllowInvalidCertificates=True,
502502
tlsCertificateKeyFile=CLIENT_PEM)
503+
self.addCleanup(noauth.close)
503504

504505
with self.assertRaises(OperationFailure):
505506
noauth.pymongo_test.test.find_one()
@@ -512,6 +513,7 @@ def test_mongodb_x509_auth(self):
512513
tlsAllowInvalidCertificates=True,
513514
tlsCertificateKeyFile=CLIENT_PEM,
514515
event_listeners=[listener])
516+
self.addCleanup(auth.close)
515517

516518
# No error
517519
auth.pymongo_test.test.find_one()
@@ -529,6 +531,7 @@ def test_mongodb_x509_auth(self):
529531
ssl=True,
530532
tlsAllowInvalidCertificates=True,
531533
tlsCertificateKeyFile=CLIENT_PEM)
534+
self.addCleanup(client.close)
532535
# No error
533536
client.pymongo_test.test.find_one()
534537

@@ -537,6 +540,7 @@ def test_mongodb_x509_auth(self):
537540
ssl=True,
538541
tlsAllowInvalidCertificates=True,
539542
tlsCertificateKeyFile=CLIENT_PEM)
543+
self.addCleanup(client.close)
540544
# No error
541545
client.pymongo_test.test.find_one()
542546
# Auth should fail if username and certificate do not match
@@ -545,7 +549,9 @@ def test_mongodb_x509_auth(self):
545549
quote_plus("not the username"), host, port))
546550

547551
bad_client = MongoClient(
548-
uri, ssl=True, tlsAllowInvalidCertificates=True, tlsCertificateKeyFile=CLIENT_PEM)
552+
uri, ssl=True, tlsAllowInvalidCertificates=True,
553+
tlsCertificateKeyFile=CLIENT_PEM)
554+
self.addCleanup(bad_client.close)
549555

550556
with self.assertRaises(OperationFailure):
551557
bad_client.pymongo_test.test.find_one()
@@ -557,6 +563,7 @@ def test_mongodb_x509_auth(self):
557563
ssl=True,
558564
tlsAllowInvalidCertificates=True,
559565
tlsCertificateKeyFile=CLIENT_PEM)
566+
self.addCleanup(bad_client.close)
560567

561568
with self.assertRaises(OperationFailure):
562569
bad_client.pymongo_test.test.find_one()

test/test_transactions.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,9 @@ def gridfs_open_upload_stream(*args, **kwargs):
290290
@client_context.require_version_min(4, 2)
291291
@client_context.require_transactions
292292
def test_transaction_starts_with_batched_write(self):
293+
if 'PyPy' in sys.version and client_context.tls:
294+
self.skipTest('PYTHON-2937 PyPy is so slow sending large '
295+
'messages over TLS that this test fails')
293296
# Start a transaction with a batch of operations that needs to be
294297
# split.
295298
listener = OvertCommandListener()
@@ -299,7 +302,8 @@ def test_transaction_starts_with_batched_write(self):
299302
listener.reset()
300303
self.addCleanup(client.close)
301304
self.addCleanup(coll.drop)
302-
ops = [InsertOne({'a': '1'*(10*1024*1024)}) for _ in range(10)]
305+
large_str = '\0'*(10*1024*1024)
306+
ops = [InsertOne({'a': large_str}) for _ in range(10)]
303307
with client.start_session() as session:
304308
with session.start_transaction():
305309
coll.bulk_write(ops, session=session)
@@ -364,6 +368,7 @@ def callback(session):
364368
def test_callback_not_retried_after_timeout(self):
365369
listener = OvertCommandListener()
366370
client = rs_client(event_listeners=[listener])
371+
self.addCleanup(client.close)
367372
coll = client[self.db.name].test
368373

369374
def callback(session):
@@ -393,6 +398,7 @@ def callback(session):
393398
def test_callback_not_retried_after_commit_timeout(self):
394399
listener = OvertCommandListener()
395400
client = rs_client(event_listeners=[listener])
401+
self.addCleanup(client.close)
396402
coll = client[self.db.name].test
397403

398404
def callback(session):
@@ -423,6 +429,7 @@ def callback(session):
423429
def test_commit_not_retried_after_timeout(self):
424430
listener = OvertCommandListener()
425431
client = rs_client(event_listeners=[listener])
432+
self.addCleanup(client.close)
426433
coll = client[self.db.name].test
427434

428435
def callback(session):

0 commit comments

Comments
 (0)