Skip to content

Commit

Permalink
Merge pull request #192 from IlyaSkriblovsky/twisted-trunk-version
Browse files Browse the repository at this point in the history
New way of getting Twisted version in trunk version
  • Loading branch information
psi29a committed Oct 10, 2016
2 parents 6225f42 + 6a2ba10 commit ce9636e
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions tests/test_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
from twisted.trial import unittest
from twisted.internet import defer
from twisted.python.compat import _PY3
from twisted import _version
try:
from twisted._version import version as twisted_version
except ImportError:
from twisted._version import __version__ as twisted_version

mongo_host = "127.0.0.1"
mongo_port = 27017
Expand Down Expand Up @@ -198,7 +201,7 @@ def test_GridFileObjects(self):
content_type="text/plain", chunk_size=65536, length=1048576,
upload_date="20150101")
self.assertFalse(grid_in_file.closed)
if _version.version.major >= 15:
if twisted_version.major >= 15:
with self.assertRaises(TypeError):
yield grid_in_file.write(1)
with self.assertRaises(TypeError):
Expand All @@ -212,7 +215,7 @@ def test_GridFileObjects(self):
"upload_date": "20150101"}
self.assertRaises(TypeError, GridOut, None, None)
grid_out_file = GridOut(db.fs, fake_doc)
if _version.version.major >= 15:
if twisted_version.major >= 15:
with self.assertRaises(AttributeError):
_ = grid_out_file.testing
self.assertEqual("test", grid_out_file.filename)
Expand All @@ -229,15 +232,15 @@ def test_GridFileObjects(self):
self.assertTrue("20150101", grid_in_file.upload_date)
yield grid_in_file.writelines([b"0xDEADBEEF", b"0xDEADBEAF"])
yield grid_in_file.close()
if _version.version.major >= 15:
if twisted_version.major >= 15:
with self.assertRaises(AttributeError):
grid_in_file.length = 1
self.assertEqual(1, grid_in_file.test)
if _version.version.major >= 15:
if twisted_version.major >= 15:
with self.assertRaises(AttributeError):
_ = grid_in_file.test_none
self.assertTrue(grid_in_file.closed)
if _version.version.major >= 15:
if twisted_version.major >= 15:
with self.assertRaises(ValueError):
yield grid_in_file.write(b"0xDEADBEEF")
yield conn.disconnect()
Expand Down Expand Up @@ -295,7 +298,7 @@ def test_GridFsIteration(self):
"chunkSize": 4096, "contentType": "text/plain"}
grid_bad_out_file = GridOut(db.fs, fake_bad_doc)
bad_iterator = GridOutIterator(grid_bad_out_file, db.fs.chunks)
if _version.version.major >= 15:
if twisted_version.major >= 15:
with self.assertRaises(errors.CorruptGridFile):
next_it = yield bad_iterator.next()

Expand Down Expand Up @@ -323,7 +326,7 @@ def test_GridFsOperations(self):
try:
# Tests writing to a new gridfs file
gfs = GridFS(db) # Default collection
if _version.version.major >= 15:
if twisted_version.major >= 15:
with self.assertRaises(NoFile):
yield gfs.get_last_version("optest")

Expand Down

0 comments on commit ce9636e

Please sign in to comment.