Bläddra i källkod

Merge pull request #16357 from tirkarthi/fix-assert-1

test: Use assertEqual instead of assertEquals for Python 3.11 compatibility.
version-14
mergify[bot] 3 år sedan
committed by GitHub
förälder
incheckning
367e3fdb4e
Ingen känd nyckel hittad för denna signaturen i databasen GPG-nyckel ID: 4AEE18F83AFDEB23
6 ändrade filer med 14 tillägg och 14 borttagningar
  1. +3
    -3
      frappe/core/doctype/file/test_file.py
  2. +1
    -1
      frappe/email/doctype/notification/test_notification.py
  3. +3
    -3
      frappe/tests/test_base_document.py
  4. +2
    -2
      frappe/tests/test_db.py
  5. +3
    -3
      frappe/tests/test_document.py
  6. +2
    -2
      frappe/tests/test_search.py

+ 3
- 3
frappe/core/doctype/file/test_file.py Visa fil

@@ -382,7 +382,7 @@ class TestFile(unittest.TestCase):
}).insert(ignore_permissions=True) }).insert(ignore_permissions=True)


test_file.make_thumbnail() test_file.make_thumbnail()
self.assertEquals(test_file.thumbnail_url, '/files/image_small.jpg')
self.assertEqual(test_file.thumbnail_url, '/files/image_small.jpg')


# test web image without extension # test web image without extension
test_file = frappe.get_doc({ test_file = frappe.get_doc({
@@ -399,7 +399,7 @@ class TestFile(unittest.TestCase):
test_file.reload() test_file.reload()
test_file.file_url = "/files/image_small.jpg" test_file.file_url = "/files/image_small.jpg"
test_file.make_thumbnail(suffix="xs", crop=True) test_file.make_thumbnail(suffix="xs", crop=True)
self.assertEquals(test_file.thumbnail_url, '/files/image_small_xs.jpg')
self.assertEqual(test_file.thumbnail_url, '/files/image_small_xs.jpg')


frappe.clear_messages() frappe.clear_messages()
test_file.db_set('thumbnail_url', None) test_file.db_set('thumbnail_url', None)
@@ -407,7 +407,7 @@ class TestFile(unittest.TestCase):
test_file.file_url = frappe.utils.get_url('unknown.jpg') test_file.file_url = frappe.utils.get_url('unknown.jpg')
test_file.make_thumbnail(suffix="xs") test_file.make_thumbnail(suffix="xs")
self.assertEqual(json.loads(frappe.message_log[0]).get("message"), f"File '{frappe.utils.get_url('unknown.jpg')}' not found") self.assertEqual(json.loads(frappe.message_log[0]).get("message"), f"File '{frappe.utils.get_url('unknown.jpg')}' not found")
self.assertEquals(test_file.thumbnail_url, None)
self.assertEqual(test_file.thumbnail_url, None)


def test_file_unzip(self): def test_file_unzip(self):
file_path = frappe.get_app_path('frappe', 'www/_test/assets/file.zip') file_path = frappe.get_app_path('frappe', 'www/_test/assets/file.zip')


+ 1
- 1
frappe/email/doctype/notification/test_notification.py Visa fil

@@ -240,7 +240,7 @@ class TestNotification(unittest.TestCase):
self.assertTrue(email_queue) self.assertTrue(email_queue)


# check if description is changed after alert since set_property_after_alert is set # check if description is changed after alert since set_property_after_alert is set
self.assertEquals(todo.description, 'Changed by Notification')
self.assertEqual(todo.description, 'Changed by Notification')


recipients = [d.recipient for d in email_queue.recipients] recipients = [d.recipient for d in email_queue.recipients]
self.assertTrue('test2@example.com' in recipients) self.assertTrue('test2@example.com' in recipients)


+ 3
- 3
frappe/tests/test_base_document.py Visa fil

@@ -7,12 +7,12 @@ class TestBaseDocument(unittest.TestCase):
def test_docstatus(self): def test_docstatus(self):
doc = BaseDocument({"docstatus": 0}) doc = BaseDocument({"docstatus": 0})
self.assertTrue(doc.docstatus.is_draft()) self.assertTrue(doc.docstatus.is_draft())
self.assertEquals(doc.docstatus, 0)
self.assertEqual(doc.docstatus, 0)


doc.docstatus = 1 doc.docstatus = 1
self.assertTrue(doc.docstatus.is_submitted()) self.assertTrue(doc.docstatus.is_submitted())
self.assertEquals(doc.docstatus, 1)
self.assertEqual(doc.docstatus, 1)


doc.docstatus = 2 doc.docstatus = 2
self.assertTrue(doc.docstatus.is_cancelled()) self.assertTrue(doc.docstatus.is_cancelled())
self.assertEquals(doc.docstatus, 2)
self.assertEqual(doc.docstatus, 2)

+ 2
- 2
frappe/tests/test_db.py Visa fil

@@ -386,7 +386,7 @@ class TestDDLCommandsMaria(unittest.TestCase):
WHERE Key_name = '{index_name}'; WHERE Key_name = '{index_name}';
""" """
) )
self.assertEquals(len(indexs_in_table), 2)
self.assertEqual(len(indexs_in_table), 2)




class TestDBSetValue(unittest.TestCase): class TestDBSetValue(unittest.TestCase):
@@ -590,7 +590,7 @@ class TestDDLCommandsPost(unittest.TestCase):
AND indexname = '{index_name}' ; AND indexname = '{index_name}' ;
""", """,
) )
self.assertEquals(len(indexs_in_table), 1)
self.assertEqual(len(indexs_in_table), 1)


@run_only_if(db_type_is.POSTGRES) @run_only_if(db_type_is.POSTGRES)
def test_modify_query(self): def test_modify_query(self):


+ 3
- 3
frappe/tests/test_document.py Visa fil

@@ -260,15 +260,15 @@ class TestDocument(unittest.TestCase):
'doctype': 'Test Formatted', 'doctype': 'Test Formatted',
'currency': 100000 'currency': 100000
}) })
self.assertEquals(d.get_formatted('currency', currency='INR', format="#,###.##"), '₹ 100,000.00')
self.assertEqual(d.get_formatted('currency', currency='INR', format="#,###.##"), '₹ 100,000.00')


def test_limit_for_get(self): def test_limit_for_get(self):
doc = frappe.get_doc("DocType", "DocType") doc = frappe.get_doc("DocType", "DocType")
# assuming DocType has more than 3 Data fields # assuming DocType has more than 3 Data fields
self.assertEquals(len(doc.get("fields", limit=3)), 3)
self.assertEqual(len(doc.get("fields", limit=3)), 3)


# limit with filters # limit with filters
self.assertEquals(len(doc.get("fields", filters={"fieldtype": "Data"}, limit=3)), 3)
self.assertEqual(len(doc.get("fields", filters={"fieldtype": "Data"}, limit=3)), 3)


def test_virtual_fields(self): def test_virtual_fields(self):
"""Virtual fields are accessible via API and Form views, whenever .as_dict is invoked """Virtual fields are accessible via API and Form views, whenever .as_dict is invoked


+ 2
- 2
frappe/tests/test_search.py Visa fil

@@ -70,10 +70,10 @@ class TestSearch(unittest.TestCase):
result = frappe.response['results'] result = frappe.response['results']


# Check whether the result is sorted or not # Check whether the result is sorted or not
self.assertEquals(self.parent_doctype_name, result[0]['value'])
self.assertEqual(self.parent_doctype_name, result[0]['value'])


# Check whether searching for parent also list out children # Check whether searching for parent also list out children
self.assertEquals(len(result), len(self.child_doctypes_names) + 1)
self.assertEqual(len(result), len(self.child_doctypes_names) + 1)


#Search for the word "pay", part of the word "pays" (country) in french. #Search for the word "pay", part of the word "pays" (country) in french.
def test_link_search_in_foreign_language(self): def test_link_search_in_foreign_language(self):


Laddar…
Avbryt
Spara