improve tests health (flake8 warnings)

This commit is contained in:
Bastien Gérard
2019-09-01 15:03:29 +03:00
parent c61c6a8525
commit bc0c55e49a
34 changed files with 97 additions and 111 deletions

View File

@@ -2,12 +2,11 @@
import uuid
from bson import Binary
from nose.plugins.skip import SkipTest
import pytest
import six
from mongoengine import *
from tests.utils import MongoDBTestCase
import pytest
BIN_VALUE = six.b(
"\xa9\xf3\x8d(\xd7\x03\x84\xb4k[\x0f\xe3\xa2\x19\x85p[J\xa3\xd2>\xde\xe6\x87\xb1\x7f\xc6\xe6\xd9r\x18\xf5"

View File

@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
from mongoengine import *
from tests.utils import MongoDBTestCase, get_as_pymongo
import pytest
from mongoengine import *
from tests.utils import MongoDBTestCase, get_as_pymongo
class TestBooleanField(MongoDBTestCase):
def test_storage(self):

View File

@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
from decimal import Decimal
from mongoengine import *
from tests.utils import MongoDBTestCase
import pytest
from mongoengine import *
from tests.utils import MongoDBTestCase
class TestCachedReferenceField(MongoDBTestCase):
def test_get_and_save(self):

View File

@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
import datetime
import pytest
import six
try:
@@ -8,9 +10,7 @@ except ImportError:
dateutil = None
from mongoengine import *
from tests.utils import MongoDBTestCase
import pytest
class TestDateField(MongoDBTestCase):

View File

@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
import datetime as dt
import pytest
import six
try:
@@ -11,7 +13,6 @@ from mongoengine import *
from mongoengine import connection
from tests.utils import MongoDBTestCase
import pytest
class TestDateTimeField(MongoDBTestCase):

View File

@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
from decimal import Decimal
from mongoengine import *
from tests.utils import MongoDBTestCase
import pytest
from mongoengine import *
from tests.utils import MongoDBTestCase
class TestDecimalField(MongoDBTestCase):
def test_validation(self):

View File

@@ -1,9 +1,10 @@
# -*- coding: utf-8 -*-
import pytest
from mongoengine import *
from mongoengine.base import BaseDict
from tests.utils import MongoDBTestCase, get_as_pymongo
import pytest
class TestDictField(MongoDBTestCase):
@@ -290,7 +291,7 @@ class TestDictField(MongoDBTestCase):
e.save()
e.update(set__mapping={"ints": [3, 4]})
e.reload()
assert BaseDict == type(e.mapping)
assert isinstance(e.mapping, BaseDict)
assert {"ints": [3, 4]} == e.mapping
# try creating an invalid mapping

View File

@@ -2,11 +2,11 @@
import sys
from unittest import SkipTest
from mongoengine import *
from tests.utils import MongoDBTestCase
import pytest
from mongoengine import *
from tests.utils import MongoDBTestCase
class TestEmailField(MongoDBTestCase):
def test_generic_behavior(self):

View File

@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
import pytest
from mongoengine import (
Document,
EmbeddedDocument,
@@ -13,7 +15,6 @@ from mongoengine import (
)
from tests.utils import MongoDBTestCase
import pytest
class TestEmbeddedDocumentField(MongoDBTestCase):

View File

@@ -4,6 +4,7 @@ import unittest
from bson import DBRef, ObjectId, SON
from nose.plugins.skip import SkipTest
import pytest
from mongoengine import (
BooleanField,
@@ -39,7 +40,6 @@ from mongoengine.base import BaseField, EmbeddedDocumentList, _document_registry
from mongoengine.errors import DeprecatedError
from tests.utils import MongoDBTestCase
import pytest
class TestField(MongoDBTestCase):
@@ -1838,7 +1838,7 @@ class TestField(MongoDBTestCase):
user = User.objects(bookmarks__all=[post_1]).first()
assert user != None
assert user is not None
assert user.bookmarks[0] == post_1
def test_generic_reference_filter_by_dbref(self):

View File

@@ -137,7 +137,6 @@ class TestFileField(MongoDBTestCase):
text = six.b("Hello, World!")
more_text = six.b("Foo Bar")
content_type = "text/plain"
streamfile = StreamFile()
streamfile.save()
@@ -205,7 +204,7 @@ class TestFileField(MongoDBTestCase):
doc_b = GridDocument.objects.with_id(doc_a.id)
doc_b.the_file.replace(f, filename="doc_b")
doc_b.save()
assert doc_b.the_file.grid_id != None
assert doc_b.the_file.grid_id is not None
# Test it matches
doc_c = GridDocument.objects.with_id(doc_b.id)

View File

@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
import pytest
import six
from mongoengine import *
from tests.utils import MongoDBTestCase
import pytest
class TestFloatField(MongoDBTestCase):

View File

@@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
import pytest
from mongoengine import *
from tests.utils import MongoDBTestCase
import pytest
class TestIntField(MongoDBTestCase):

View File

@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
from bson import DBRef, ObjectId
import pytest
from mongoengine import *
from mongoengine.base import LazyReference
from tests.utils import MongoDBTestCase
import pytest
class TestLazyReferenceField(MongoDBTestCase):

View File

@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
import pytest
import six
try:
@@ -10,7 +11,6 @@ from mongoengine import *
from mongoengine.connection import get_db
from tests.utils import MongoDBTestCase
import pytest
class TestLongField(MongoDBTestCase):

View File

@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
import datetime
from mongoengine import *
from tests.utils import MongoDBTestCase
import pytest
from mongoengine import *
from tests.utils import MongoDBTestCase
class TestMapField(MongoDBTestCase):
def test_mapfield(self):

View File

@@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-
from bson import DBRef, SON
import pytest
from mongoengine import *
from tests.utils import MongoDBTestCase
import pytest
class TestReferenceField(MongoDBTestCase):
@@ -59,21 +58,6 @@ class TestReferenceField(MongoDBTestCase):
with pytest.raises(ValidationError):
post1.validate()
def test_objectid_reference_fields(self):
"""Make sure storing Object ID references works."""
class Person(Document):
name = StringField()
parent = ReferenceField("self")
Person.drop_collection()
p1 = Person(name="John").save()
Person(name="Ross", parent=p1.pk).save()
p = Person.objects.get(name="Ross")
assert p.parent == p1
def test_dbref_reference_fields(self):
"""Make sure storing references as bson.dbref.DBRef works."""

View File

@@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
import pytest
from mongoengine import *
from tests.utils import MongoDBTestCase
import pytest
class TestURLField(MongoDBTestCase):

View File

@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
import uuid
from mongoengine import *
from tests.utils import MongoDBTestCase, get_as_pymongo
import pytest
from mongoengine import *
from tests.utils import MongoDBTestCase, get_as_pymongo
class Person(Document):
api_key = UUIDField(binary=False)