autoformat with pyupgrade

This commit is contained in:
Bastien Gerard
2020-12-08 23:14:33 +01:00
parent c00a378776
commit eabb8f60f5
36 changed files with 207 additions and 212 deletions

View File

@@ -55,7 +55,7 @@ class TestFileField(MongoDBTestCase):
PutFile.drop_collection()
text = "Hello, World!".encode("latin-1")
text = b"Hello, World!"
content_type = "text/plain"
putfile = PutFile()
@@ -97,8 +97,8 @@ class TestFileField(MongoDBTestCase):
StreamFile.drop_collection()
text = "Hello, World!".encode("latin-1")
more_text = "Foo Bar".encode("latin-1")
text = b"Hello, World!"
more_text = b"Foo Bar"
content_type = "text/plain"
streamfile = StreamFile()
@@ -133,8 +133,8 @@ class TestFileField(MongoDBTestCase):
StreamFile.drop_collection()
text = "Hello, World!".encode("latin-1")
more_text = "Foo Bar".encode("latin-1")
text = b"Hello, World!"
more_text = b"Foo Bar"
streamfile = StreamFile()
streamfile.save()
@@ -163,8 +163,8 @@ class TestFileField(MongoDBTestCase):
class SetFile(Document):
the_file = FileField()
text = "Hello, World!".encode("latin-1")
more_text = "Foo Bar".encode("latin-1")
text = b"Hello, World!"
more_text = b"Foo Bar"
SetFile.drop_collection()
@@ -192,7 +192,7 @@ class TestFileField(MongoDBTestCase):
GridDocument.drop_collection()
with tempfile.TemporaryFile() as f:
f.write("Hello World!".encode("latin-1"))
f.write(b"Hello World!")
f.flush()
# Test without default
@@ -209,7 +209,7 @@ class TestFileField(MongoDBTestCase):
assert doc_b.the_file.grid_id == doc_c.the_file.grid_id
# Test with default
doc_d = GridDocument(the_file="".encode("latin-1"))
doc_d = GridDocument(the_file=b"")
doc_d.save()
doc_e = GridDocument.objects.with_id(doc_d.id)
@@ -235,7 +235,7 @@ class TestFileField(MongoDBTestCase):
# First instance
test_file = TestFile()
test_file.name = "Hello, World!"
test_file.the_file.put("Hello, World!".encode("latin-1"))
test_file.the_file.put(b"Hello, World!")
test_file.save()
# Second instance
@@ -291,9 +291,7 @@ class TestFileField(MongoDBTestCase):
test_file = TestFile()
assert not bool(test_file.the_file)
test_file.the_file.put(
"Hello, World!".encode("latin-1"), content_type="text/plain"
)
test_file.the_file.put(b"Hello, World!", content_type="text/plain")
test_file.save()
assert bool(test_file.the_file)
@@ -315,7 +313,7 @@ class TestFileField(MongoDBTestCase):
class TestFile(Document):
the_file = FileField()
text = "Hello, World!".encode("latin-1")
text = b"Hello, World!"
content_type = "text/plain"
testfile = TestFile()
@@ -359,7 +357,7 @@ class TestFileField(MongoDBTestCase):
testfile.the_file.put(text, content_type=content_type, filename="hello")
testfile.save()
text = "Bonjour, World!".encode("latin-1")
text = b"Bonjour, World!"
testfile.the_file.replace(text, content_type=content_type, filename="hello")
testfile.save()
@@ -383,7 +381,7 @@ class TestFileField(MongoDBTestCase):
TestImage.drop_collection()
with tempfile.TemporaryFile() as f:
f.write("Hello World!".encode("latin-1"))
f.write(b"Hello World!")
f.flush()
t = TestImage()
@@ -499,21 +497,21 @@ class TestFileField(MongoDBTestCase):
# First instance
test_file = TestFile()
test_file.name = "Hello, World!"
test_file.the_file.put("Hello, World!".encode("latin-1"), name="hello.txt")
test_file.the_file.put(b"Hello, World!", name="hello.txt")
test_file.save()
data = get_db("test_files").macumba.files.find_one()
assert data.get("name") == "hello.txt"
test_file = TestFile.objects.first()
assert test_file.the_file.read() == "Hello, World!".encode("latin-1")
assert test_file.the_file.read() == b"Hello, World!"
test_file = TestFile.objects.first()
test_file.the_file = "Hello, World!".encode("latin-1")
test_file.the_file = b"Hello, World!"
test_file.save()
test_file = TestFile.objects.first()
assert test_file.the_file.read() == "Hello, World!".encode("latin-1")
assert test_file.the_file.read() == b"Hello, World!"
def test_copyable(self):
class PutFile(Document):
@@ -521,7 +519,7 @@ class TestFileField(MongoDBTestCase):
PutFile.drop_collection()
text = "Hello, World!".encode("latin-1")
text = b"Hello, World!"
content_type = "text/plain"
putfile = PutFile()