black reformat

This commit is contained in:
Ido Shraga 2021-10-01 07:48:01 +03:00
parent 3d6b650592
commit 7a0a58c163
2 changed files with 15 additions and 18 deletions

View File

@ -163,7 +163,7 @@ class StringField(BaseField):
regex = value
# escape unsafe characters which could lead to a re.error
if op == 'regex':
if op == "regex":
value = re.compile(regex, flags)
else:
value = re.escape(value)
@ -1093,9 +1093,7 @@ class DictField(ComplexBaseField):
return DictField(db_field=member_name)
def prepare_query_value(self, op, value):
match_operators = [
*STRING_OPERATORS
]
match_operators = [*STRING_OPERATORS]
if op in match_operators and isinstance(value, str):
return StringField().prepare_query_value(op, value)

View File

@ -872,17 +872,15 @@ class TestQueryset(unittest.TestCase):
self.Person.objects.create(name="Foo", age=11)
bob = self.Person.objects.as_pymongo().first()
assert 'age' in bob
assert bob['age'] == 11
assert "age" in bob
assert bob["age"] == 11
self.Person.objects(name="Foo").update(
rename__age='person_age'
)
self.Person.objects(name="Foo").update(rename__age="person_age")
bob = self.Person.objects.as_pymongo().first()
assert 'age' not in bob
assert 'person_age' in bob
assert bob['person_age'] == 11
assert "age" not in bob
assert "person_age" in bob
assert bob["person_age"] == 11
def test_save_and_only_on_fields_with_default(self):
class Embed(EmbeddedDocument):
@ -1257,7 +1255,6 @@ class TestQueryset(unittest.TestCase):
obj = self.Person.objects(name__iexact="gUIDO VAN rOSSU").first()
assert obj is None
# Test wholeword
obj = self.Person.objects(name__wholeword="Guido").first()
assert obj == person
@ -1370,12 +1367,14 @@ class TestQueryset(unittest.TestCase):
person.save()
people = self.Person.objects
people = people.filter(name__startswith="Gui")\
.filter(name__not__endswith="tum")\
.filter(name__icontains="VAN")\
.filter(name__regex="^Guido")\
.filter(name__wholeword="Guido")\
people = (
people.filter(name__startswith="Gui")
.filter(name__not__endswith="tum")
.filter(name__icontains="VAN")
.filter(name__regex="^Guido")
.filter(name__wholeword="Guido")
.filter(name__wholeword="van")
)
assert people.count() == 1
def assertSequence(self, qs, expected):