fix: Create a bad unicode file differently.
In Python 3.11 CSV files are allowed to have null characters so the test data is no longer a valid. We update it to not have a valid unicode character to still test this code path correctly. I'm not concerned about the fact that the files with null will get past this test beacause there are other checks on the content of the file that catch if it doesn't have enough or the right fields so this should be a safe change to make to the tests. Relevant Change in Python: https://github.com/python/cpython/issues/71767
This commit is contained in:
@@ -713,7 +713,7 @@ class TestInstructorAPIBulkAccountCreationAndEnrollment(SharedModuleStoreTestCas
|
||||
"""
|
||||
Try uploading some non-CSV file and verify that it is rejected
|
||||
"""
|
||||
uploaded_file = SimpleUploadedFile("temp.csv", io.BytesIO(b"some initial binary data: \x00\x01").read())
|
||||
uploaded_file = SimpleUploadedFile("temp.csv", io.BytesIO(b"some initial binary data: \xC3\x01").read())
|
||||
response = self.client.post(self.url, {'students_list': uploaded_file})
|
||||
assert response.status_code == 200
|
||||
data = json.loads(response.content.decode('utf-8'))
|
||||
|
||||
@@ -888,7 +888,7 @@ class TestCertificatesInstructorApiBulkAllowlist(SharedModuleStoreTestCase):
|
||||
"""
|
||||
Try uploading CSV file with invalid binary data and verify that it is rejected
|
||||
"""
|
||||
uploaded_file = SimpleUploadedFile("temp.csv", io.BytesIO(b"some initial binary data: \x00\x01").read())
|
||||
uploaded_file = SimpleUploadedFile("temp.csv", io.BytesIO(b"some initial binary data: \xC3\x01").read())
|
||||
response = self.client.post(self.url, {'students_list': uploaded_file})
|
||||
assert response.status_code == 200
|
||||
data = json.loads(response.content.decode('utf-8'))
|
||||
|
||||
Reference in New Issue
Block a user