Skip to content

Commit 461e252

Browse files
author
A. Jesse Jiryu Davis
committed
Informative message whenever skipping a test
1 parent 880ba27 commit 461e252

11 files changed

+37
-34
lines changed

test/test_binary.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def test_repr(self):
9494

9595
def test_legacy_java_uuid(self):
9696
if not should_test_uuid:
97-
raise SkipTest()
97+
raise SkipTest("No uuid module")
9898

9999
# Generated by the Java driver
100100
from_java = b('bAAAAAdfaWQAUCBQxkVm+XdxJ9tOBW5ld2d1aWQAEAAAAAMIQkfACFu'
@@ -166,7 +166,7 @@ def test_legacy_java_uuid(self):
166166

167167
def test_legacy_csharp_uuid(self):
168168
if not should_test_uuid:
169-
raise SkipTest()
169+
raise SkipTest("No uuid module")
170170

171171
# Generated by the .net driver
172172
from_csharp = b('ZAAAABBfaWQAAAAAAAVuZXdndWlkABAAAAAD+MkoCd/Jy0iYJ7Vhl'
@@ -237,7 +237,7 @@ def test_legacy_csharp_uuid(self):
237237

238238
def test_uuid_queries(self):
239239
if not should_test_uuid:
240-
raise SkipTest()
240+
raise SkipTest("No uuid module")
241241

242242
c = get_connection()
243243
coll = c.pymongo_test.test

test/test_bson.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def test_tuple(self):
310310

311311
def test_uuid(self):
312312
if not should_test_uuid:
313-
raise SkipTest()
313+
raise SkipTest("No uuid module")
314314

315315
id = uuid.uuid4()
316316
transformed_id = (BSON.encode({"id": id})).decode()["id"]
@@ -321,7 +321,7 @@ def test_uuid(self):
321321

322322
def test_uuid_legacy(self):
323323
if not should_test_uuid:
324-
raise SkipTest()
324+
raise SkipTest("No uuid module")
325325

326326
id = uuid.uuid4()
327327
legacy = UUIDLegacy(id)
@@ -437,7 +437,7 @@ def test_ordered_dict(self):
437437
try:
438438
from collections import OrderedDict
439439
except ImportError:
440-
raise SkipTest()
440+
raise SkipTest("No OrderedDict")
441441
d = OrderedDict([("one", 1), ("two", 2), ("three", 3), ("four", 4)])
442442
self.assertEqual(d, BSON.encode(d).decode(as_class=OrderedDict))
443443

test/test_collection.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ def test_duplicate_key_error(self):
880880
def test_continue_on_error(self):
881881
db = self.db
882882
if not version.at_least(db.connection, (1, 9, 1)):
883-
raise SkipTest()
883+
raise SkipTest("continue_on_error requires MongoDB >= 1.9.1")
884884

885885
db.drop_collection("test")
886886
oid = db.test.insert({"one": 1})
@@ -966,7 +966,7 @@ def test_update(self):
966966
def test_multi_update(self):
967967
db = self.db
968968
if not version.at_least(db.connection, (1, 1, 3, -1)):
969-
raise SkipTest()
969+
raise SkipTest("multi-update requires MongoDB >= 1.1.3")
970970

971971
db.drop_collection("test")
972972

@@ -1060,7 +1060,7 @@ def test_safe_remove(self):
10601060

10611061
def test_last_error_options(self):
10621062
if not version.at_least(self.connection, (1, 5, 1)):
1063-
raise SkipTest()
1063+
raise SkipTest("getLastError options require MongoDB >= 1.5.1")
10641064

10651065
# XXX: Fix this if we ever have a replica set unittest env.
10661066
# mongo >=1.7.6 errors with 'norepl' when w=2+
@@ -1406,7 +1406,7 @@ def test_cursor_timeout(self):
14061406

14071407
def test_distinct(self):
14081408
if not version.at_least(self.db.connection, (1, 1)):
1409-
raise SkipTest()
1409+
raise SkipTest("distinct command requires MongoDB >= 1.1")
14101410

14111411
self.db.drop_collection("test")
14121412

@@ -1486,7 +1486,7 @@ def test_insert_large_document(self):
14861486

14871487
def test_map_reduce(self):
14881488
if not version.at_least(self.db.connection, (1, 1, 1)):
1489-
raise SkipTest()
1489+
raise SkipTest("mapReduce command requires MongoDB >= 1.1.1")
14901490

14911491
db = self.db
14921492
db.drop_collection("test")
@@ -1672,7 +1672,7 @@ class ExtendedDict(dict):
16721672

16731673
def test_find_with_nested(self):
16741674
if not version.at_least(self.db.connection, (2, 0, 0)):
1675-
raise SkipTest()
1675+
raise SkipTest("nested $and and $or requires MongoDB >= 2.0")
16761676
c = self.db.test
16771677
c.drop()
16781678
c.insert([{'i': i} for i in range(5)]) # [0, 1, 2, 3, 4]
@@ -1740,7 +1740,7 @@ def transform_outgoing(self, son, collection):
17401740

17411741
def test_uuid_subtype(self):
17421742
if not have_uuid:
1743-
raise SkipTest()
1743+
raise SkipTest("No uuid module")
17441744

17451745
coll = self.connection.pymongo_test.uuid
17461746
coll.drop()

test/test_connection.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,12 @@ def test_from_uri(self):
277277
def test_fork(self):
278278
# Test using a connection before and after a fork.
279279
if sys.platform == "win32":
280-
raise SkipTest()
280+
raise SkipTest("Can't fork on windows")
281281

282282
try:
283283
from multiprocessing import Process, Pipe
284284
except ImportError:
285-
raise SkipTest()
285+
raise SkipTest("No multiprocessing module")
286286

287287
db = Connection(self.host, self.port).pymongo_test
288288

@@ -452,7 +452,7 @@ def test_fsync_lock_unlock(self):
452452

453453
def test_contextlib(self):
454454
if sys.version_info < (2, 6):
455-
raise SkipTest()
455+
raise SkipTest("With statement requires Python >= 2.6")
456456

457457
import contextlib
458458

test/test_cursor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ def test_getitem_numeric_index(self):
634634

635635
def test_count_with_limit_and_skip(self):
636636
if not version.at_least(self.db.connection, (1, 1, 4, -1)):
637-
raise SkipTest()
637+
raise SkipTest("count with limit / skip requires MongoDB >= 1.1.4")
638638

639639
def check_len(cursor, length):
640640
self.assertEqual(len(list(cursor)), cursor.count(True))
@@ -707,7 +707,7 @@ def test_tailable(self):
707707

708708
def test_distinct(self):
709709
if not version.at_least(self.db.connection, (1, 1, 3, 1)):
710-
raise SkipTest()
710+
raise SkipTest("distinct with query requires MongoDB >= 1.1.3")
711711

712712
self.db.drop_collection("test")
713713

@@ -736,7 +736,7 @@ def test_distinct(self):
736736

737737
def test_max_scan(self):
738738
if not version.at_least(self.db.connection, (1, 5, 1)):
739-
raise SkipTest()
739+
raise SkipTest("maxScan requires MongoDB >= 1.5.1")
740740

741741
self.db.drop_collection("test")
742742
for _ in range(100):
@@ -749,7 +749,7 @@ def test_max_scan(self):
749749

750750
def test_with_statement(self):
751751
if sys.version_info < (2, 6):
752-
raise SkipTest()
752+
raise SkipTest("With statement requires Python >= 2.6")
753753

754754
self.db.drop_collection("test")
755755
for _ in range(100):

test/test_grid_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ def test_set_after_close(self):
477477

478478
def test_context_manager(self):
479479
if sys.version_info < (2, 6):
480-
raise SkipTest()
480+
raise SkipTest("With statement requires Python >= 2.6")
481481

482482
contents = b("Imagine this is some important data...")
483483
# Hack around python2.4 an 2.5 not supporting 'with' syntax

test/test_json_util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class TestJsonUtil(unittest.TestCase):
4444

4545
def setUp(self):
4646
if not json_util.json_lib:
47-
raise SkipTest()
47+
raise SkipTest("No json or simplejson module")
4848

4949
self.db = get_connection().pymongo_test
5050

@@ -105,7 +105,7 @@ def test_timestamp(self):
105105

106106
def test_uuid(self):
107107
if not bson.has_uuid():
108-
raise SkipTest()
108+
raise SkipTest("No uuid module")
109109
self.round_trip(
110110
{'uuid': bson.uuid.UUID(
111111
'f47ac10b-58cc-4372-a567-0e02b2c3d479')})

test/test_master_slave_connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def setUp(self):
5757
pass
5858

5959
if not self.slaves:
60-
raise SkipTest()
60+
raise SkipTest("Not connected to master-slave set")
6161

6262
self.connection = MasterSlaveConnection(self.master, self.slaves)
6363
self.db = self.connection.pymongo_test

test/test_objectid.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ def test_multiprocessing(self):
9595
# multiprocessing on windows is weird and I don't feel like figuring it
9696
# out right now. this should fix buildbot.
9797
if sys.platform == "win32":
98-
raise SkipTest()
98+
raise SkipTest("Can't fork on Windows")
9999

100100
try:
101101
import multiprocessing
102102
except ImportError:
103-
raise SkipTest()
103+
raise SkipTest("Can't fork on Windows")
104104

105105
pool = multiprocessing.Pool(2)
106106
ids = pool.map(oid, range(20))

test/test_replica_set_connection.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def setUp(self):
5757
conn = Connection(pair)
5858
response = conn.admin.command('ismaster')
5959
if 'setName' in response:
60-
raise SkipTest()
60+
raise SkipTest("Not connected to a replica set")
6161

6262
def test_connect(self):
6363
self.assertRaises(ConfigurationError, ReplicaSetConnection,
@@ -89,7 +89,7 @@ def setUp(self):
8989
if m['stateStr'] == 'SECONDARY'
9090
]
9191
else:
92-
raise SkipTest()
92+
raise SkipTest("Not connected to a replica set")
9393

9494
def _get_connection(self, **kwargs):
9595
return ReplicaSetConnection(pair,
@@ -376,12 +376,12 @@ def test_fork(self):
376376
"""Test using a connection before and after a fork.
377377
"""
378378
if sys.platform == "win32":
379-
raise SkipTest()
379+
raise SkipTest("Can't fork on Windows")
380380

381381
try:
382382
from multiprocessing import Process, Pipe
383383
except ImportError:
384-
raise SkipTest()
384+
raise SkipTest("No multiprocessing module")
385385

386386
db = self._get_connection().pymongo_test
387387

@@ -516,7 +516,7 @@ def test_ipv6(self):
516516
except:
517517
# Either mongod was started without --ipv6
518518
# or the OS doesn't support it (or both).
519-
raise SkipTest()
519+
raise SkipTest("Not connected to a replica set")
520520

521521
# Try a few simple things
522522
connection = ReplicaSetConnection("mongodb://[::1]:%d" % (port,),

0 commit comments

Comments
 (0)