Skip to content

Commit

Permalink
[pre-commit.ci lite] apply automatic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci-lite[bot] authored Sep 21, 2023
1 parent decedb0 commit 50efcb0
Show file tree
Hide file tree
Showing 39 changed files with 374 additions and 333 deletions.
24 changes: 12 additions & 12 deletions src/App/tests/test_ApplicationManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def test_holds_db(self):
db = object()
parent_jar = object()
fc = self._makeOne(db, parent_jar)
self.assertTrue(fc.db() is db)
self.assertIs(fc.db(), db)


class ConfigurationViewerTests(ConfigTestBase, unittest.TestCase):
Expand Down Expand Up @@ -204,10 +204,10 @@ def test___getitem___hit(self):
found = dc['foo']
self.assertIsInstance(found, AltDatabaseManager)
self.assertEqual(found.id, 'foo')
self.assertTrue(found.__parent__ is dc)
self.assertIs(found.__parent__, dc)
conn = found._p_jar
self.assertIsInstance(conn, FakeConnection)
self.assertTrue(conn.db() is foo)
self.assertIs(conn.db(), foo)

def test___bobo_traverse___miss(self):
self._makeConfig(foo=object(), bar=object(), qux=object())
Expand All @@ -227,10 +227,10 @@ def test___bobo_traverse___hit_db(self):
found = dc.__bobo_traverse__(None, 'foo')
self.assertIsInstance(found, AltDatabaseManager)
self.assertEqual(found.id, 'foo')
self.assertTrue(found.__parent__ is dc)
self.assertIs(found.__parent__, dc)
conn = found._p_jar
self.assertIsInstance(conn, FakeConnection)
self.assertTrue(conn.db() is foo)
self.assertIs(conn.db(), foo)

def test___bobo_traverse___miss_db_hit_attr(self):
foo = object()
Expand All @@ -241,7 +241,7 @@ def test___bobo_traverse___miss_db_hit_attr(self):
dc = self._makeOne().__of__(root)
dc.spam = spam = object()
found = dc.__bobo_traverse__(None, 'spam')
self.assertTrue(found is spam)
self.assertIs(found, spam)


class ApplicationManagerTests(ConfigTestBase, unittest.TestCase):
Expand Down Expand Up @@ -493,11 +493,11 @@ def test_refcount_no_limit(self):
pairs = dm.refcount()
# XXX : Ugly empiricism here: I don't know why the count is up 1.
foo_count = sys.getrefcount(Foo)
self.assertTrue((foo_count + 1, 'foo.Foo') in pairs)
self.assertIn((foo_count + 1, 'foo.Foo'), pairs)
bar_count = sys.getrefcount(Bar)
self.assertTrue((bar_count + 1, 'foo.Bar') in pairs)
self.assertIn((bar_count + 1, 'foo.Bar'), pairs)
baz_count = sys.getrefcount(Baz)
self.assertTrue((baz_count + 1, 'qux.Baz') in pairs)
self.assertIn((baz_count + 1, 'qux.Baz'), pairs)

def test_refdict(self):
import sys
Expand Down Expand Up @@ -539,7 +539,7 @@ def test_rcdate(self):
dm = self._makeOne('test')
found = dm.rcdate()
App.ApplicationManager._v_rst = None
self.assertTrue(found is dummy)
self.assertIs(found, dummy)

def test_rcdeltas(self):
dm = self._makeOne('test')
Expand All @@ -548,8 +548,8 @@ def test_rcdeltas(self):
mappings = dm.rcdeltas()
self.assertTrue(len(mappings))
mapping = mappings[0]
self.assertTrue('rc' in mapping)
self.assertTrue('pc' in mapping)
self.assertIn('rc', mapping)
self.assertIn('pc', mapping)
self.assertEqual(mapping['delta'], mapping['rc'] - mapping['pc'])

# def test_dbconnections(self): XXX -- TOO UGLY TO TEST
Expand Down
8 changes: 4 additions & 4 deletions src/OFS/tests/testAppInitializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_install_virtual_hosting(self):
i = self.getOne()
i.install_virtual_hosting()
app = i.getApp()
self.assertTrue('virtual_hosting' in app)
self.assertIn('virtual_hosting', app)
self.assertEqual(
app.virtual_hosting.meta_type, 'Virtual Host Monster')

Expand All @@ -93,8 +93,8 @@ def test_install_required_roles(self):
i = self.getOne()
i.install_required_roles()
app = i.getApp()
self.assertTrue('Owner' in app.__ac_roles__)
self.assertTrue('Authenticated' in app.__ac_roles__)
self.assertIn('Owner', app.__ac_roles__)
self.assertIn('Authenticated', app.__ac_roles__)

def test_install_inituser(self):
fname = os.path.join(self.TEMPNAME, 'inituser')
Expand Down Expand Up @@ -122,7 +122,7 @@ def test_install_root_view(self):
i = self.getOne()
i.install_root_view()
app = i.getApp()
self.assertTrue('index_html' in app)
self.assertIn('index_html', app)
self.assertEqual(app.index_html.meta_type, 'Page Template')

def test_install_products_which_need_the_application(self):
Expand Down
124 changes: 62 additions & 62 deletions src/OFS/tests/testCopySupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,56 +136,56 @@ def test_interfaces(self):
verifyClass(ICopySource, CopySource)

def testRename(self):
self.assertTrue('file' in self.folder1.objectIds())
self.assertIn('file', self.folder1.objectIds())
self.folder1.manage_renameObject(id='file', new_id='filex')
self.assertFalse('file' in self.folder1.objectIds())
self.assertTrue('filex' in self.folder1.objectIds())
self.assertNotIn('file', self.folder1.objectIds())
self.assertIn('filex', self.folder1.objectIds())

def testCopy(self):
self.assertTrue('file' in self.folder1.objectIds())
self.assertFalse('file' in self.folder2.objectIds())
self.assertIn('file', self.folder1.objectIds())
self.assertNotIn('file', self.folder2.objectIds())
cookie = self.folder1.manage_copyObjects(ids=('file',))
self.folder2.manage_pasteObjects(cookie)
self.assertTrue('file' in self.folder1.objectIds())
self.assertTrue('file' in self.folder2.objectIds())
self.assertIn('file', self.folder1.objectIds())
self.assertIn('file', self.folder2.objectIds())

def testCut(self):
self.assertTrue('file' in self.folder1.objectIds())
self.assertFalse('file' in self.folder2.objectIds())
self.assertIn('file', self.folder1.objectIds())
self.assertNotIn('file', self.folder2.objectIds())
cookie = self.folder1.manage_cutObjects(ids=('file',))
self.folder2.manage_pasteObjects(cookie)
self.assertFalse('file' in self.folder1.objectIds())
self.assertTrue('file' in self.folder2.objectIds())
self.assertNotIn('file', self.folder1.objectIds())
self.assertIn('file', self.folder2.objectIds())

def testCopyNewObject(self):
self.assertFalse('newfile' in self.folder1.objectIds())
self.assertNotIn('newfile', self.folder1.objectIds())
manage_addFile(self.folder1, 'newfile',
file=b'', content_type='text/plain')
cookie = self.folder1.manage_copyObjects(ids=('newfile',))
self.folder2.manage_pasteObjects(cookie)
self.assertTrue('newfile' in self.folder1.objectIds())
self.assertTrue('newfile' in self.folder2.objectIds())
self.assertIn('newfile', self.folder1.objectIds())
self.assertIn('newfile', self.folder2.objectIds())

def testPasteSingleNotSameID(self):
self.assertTrue('file' in self.folder1.objectIds())
self.assertFalse('file' in self.folder2.objectIds())
self.assertIn('file', self.folder1.objectIds())
self.assertNotIn('file', self.folder2.objectIds())
cookie = self.folder1.manage_copyObjects(ids=('file',))
result = self.folder2.manage_pasteObjects(cookie)
self.assertTrue('file' in self.folder1.objectIds())
self.assertTrue('file' in self.folder2.objectIds())
self.assertTrue(result == [{'id': 'file', 'new_id': 'file'}])
self.assertIn('file', self.folder1.objectIds())
self.assertIn('file', self.folder2.objectIds())
self.assertEqual(result, [{'id': 'file', 'new_id': 'file'}])

def testPasteSingleSameID(self):
self.assertTrue('file' in self.folder1.objectIds())
self.assertFalse('file' in self.folder2.objectIds())
self.assertIn('file', self.folder1.objectIds())
self.assertNotIn('file', self.folder2.objectIds())
manage_addFile(self.folder2, 'file',
file=b'', content_type='text/plain')
cookie = self.folder1.manage_copyObjects(ids=('file',))
result = self.folder2.manage_pasteObjects(cookie)
self.assertTrue('file' in self.folder1.objectIds())
self.assertTrue('file' in self.folder2.objectIds())
self.assertTrue('copy_of_file' in self.folder2.objectIds())
self.assertTrue(result == [{'id': 'file', 'new_id': 'copy_of_file'}])
self.assertIn('file', self.folder1.objectIds())
self.assertIn('file', self.folder2.objectIds())
self.assertIn('copy_of_file', self.folder2.objectIds())
self.assertEqual(result, [{'id': 'file', 'new_id': 'copy_of_file'}])

def testPasteSingleSameIDMultipleTimes(self):
cookie = self.folder1.manage_copyObjects(ids=('file',))
Expand Down Expand Up @@ -225,60 +225,60 @@ def testPasteSpecialName(self):
self.assertEqual(result, [{'id': 'copy_of_', 'new_id': 'copy2_of_'}])

def testPasteMultiNotSameID(self):
self.assertTrue('file' in self.folder1.objectIds())
self.assertFalse('file1' in self.folder1.objectIds())
self.assertIn('file', self.folder1.objectIds())
self.assertNotIn('file1', self.folder1.objectIds())
manage_addFile(self.folder1, 'file1',
file=b'', content_type='text/plain')
self.assertFalse('file2' in self.folder1.objectIds())
self.assertNotIn('file2', self.folder1.objectIds())
manage_addFile(self.folder1, 'file2',
file=b'', content_type='text/plain')
self.assertFalse('file' in self.folder2.objectIds())
self.assertFalse('file1' in self.folder2.objectIds())
self.assertFalse('file2' in self.folder2.objectIds())
self.assertNotIn('file', self.folder2.objectIds())
self.assertNotIn('file1', self.folder2.objectIds())
self.assertNotIn('file2', self.folder2.objectIds())
cookie = self.folder1.manage_copyObjects(
ids=('file', 'file1', 'file2',))
result = self.folder2.manage_pasteObjects(cookie)
self.assertTrue('file' in self.folder1.objectIds())
self.assertTrue('file1' in self.folder1.objectIds())
self.assertTrue('file2' in self.folder1.objectIds())
self.assertTrue('file' in self.folder2.objectIds())
self.assertTrue('file1' in self.folder2.objectIds())
self.assertTrue('file2' in self.folder2.objectIds())
self.assertIn('file', self.folder1.objectIds())
self.assertIn('file1', self.folder1.objectIds())
self.assertIn('file2', self.folder1.objectIds())
self.assertIn('file', self.folder2.objectIds())
self.assertIn('file1', self.folder2.objectIds())
self.assertIn('file2', self.folder2.objectIds())
self.assertEqual(result, [
{'id': 'file', 'new_id': 'file'},
{'id': 'file1', 'new_id': 'file1'},
{'id': 'file2', 'new_id': 'file2'},
])

def testPasteMultiSameID(self):
self.assertTrue('file' in self.folder1.objectIds())
self.assertFalse('file1' in self.folder1.objectIds())
self.assertIn('file', self.folder1.objectIds())
self.assertNotIn('file1', self.folder1.objectIds())
manage_addFile(self.folder1, 'file1',
file=b'', content_type='text/plain')
self.assertFalse('file2' in self.folder1.objectIds())
self.assertNotIn('file2', self.folder1.objectIds())
manage_addFile(self.folder1, 'file2',
file=b'', content_type='text/plain')
self.assertFalse('file' in self.folder2.objectIds())
self.assertNotIn('file', self.folder2.objectIds())
manage_addFile(self.folder2, 'file',
file=b'', content_type='text/plain')
self.assertFalse('file1' in self.folder2.objectIds())
self.assertNotIn('file1', self.folder2.objectIds())
manage_addFile(self.folder2, 'file1',
file=b'', content_type='text/plain')
self.assertFalse('file2' in self.folder2.objectIds())
self.assertNotIn('file2', self.folder2.objectIds())
manage_addFile(self.folder2, 'file2',
file=b'', content_type='text/plain')
cookie = self.folder1.manage_copyObjects(
ids=('file', 'file1', 'file2',))
result = self.folder2.manage_pasteObjects(cookie)
self.assertTrue('file' in self.folder1.objectIds())
self.assertTrue('file1' in self.folder1.objectIds())
self.assertTrue('file2' in self.folder1.objectIds())
self.assertTrue('file' in self.folder2.objectIds())
self.assertTrue('file1' in self.folder2.objectIds())
self.assertTrue('file2' in self.folder2.objectIds())
self.assertTrue('copy_of_file' in self.folder2.objectIds())
self.assertTrue('copy_of_file1' in self.folder2.objectIds())
self.assertTrue('copy_of_file2' in self.folder2.objectIds())
self.assertIn('file', self.folder1.objectIds())
self.assertIn('file1', self.folder1.objectIds())
self.assertIn('file2', self.folder1.objectIds())
self.assertIn('file', self.folder2.objectIds())
self.assertIn('file1', self.folder2.objectIds())
self.assertIn('file2', self.folder2.objectIds())
self.assertIn('copy_of_file', self.folder2.objectIds())
self.assertIn('copy_of_file1', self.folder2.objectIds())
self.assertIn('copy_of_file2', self.folder2.objectIds())
self.assertEqual(result, [
{'id': 'file', 'new_id': 'copy_of_file'},
{'id': 'file1', 'new_id': 'copy_of_file1'},
Expand Down Expand Up @@ -406,14 +406,14 @@ def test_copy_baseline(self):

self._initPolicyAndUser()

self.assertTrue('file' in folder1.objectIds())
self.assertFalse('file' in folder2.objectIds())
self.assertIn('file', folder1.objectIds())
self.assertNotIn('file', folder2.objectIds())

cookie = folder1.manage_copyObjects(ids=('file', ))
folder2.manage_pasteObjects(cookie)

self.assertTrue('file' in folder1.objectIds())
self.assertTrue('file' in folder2.objectIds())
self.assertIn('file', folder1.objectIds())
self.assertIn('file', folder2.objectIds())

def test_copy_cant_read_source(self):
folder1, folder2 = self._initFolders()
Expand Down Expand Up @@ -470,24 +470,24 @@ def test_copy_cant_copy_invisible_items(self):
new_id = copy_info[0]['new_id']
new_folder = folder2[new_id]
# The private item should not be in the copy.
self.assertTrue('private' not in new_folder.objectIds())
self.assertNotIn('private', new_folder.objectIds())
# There is nothing wrong with copying the public item.
self.assertTrue('public' in new_folder.objectIds())
self.assertIn('public', new_folder.objectIds())

def test_move_baseline(self):
folder1, folder2 = self._initFolders()
folder2.all_meta_types = FILE_META_TYPES

self.assertTrue('file' in folder1.objectIds())
self.assertFalse('file' in folder2.objectIds())
self.assertIn('file', folder1.objectIds())
self.assertNotIn('file', folder2.objectIds())

self._initPolicyAndUser()

cookie = folder1.manage_cutObjects(ids=('file', ))
folder2.manage_pasteObjects(cookie)

self.assertFalse('file' in folder1.objectIds())
self.assertTrue('file' in folder2.objectIds())
self.assertNotIn('file', folder1.objectIds())
self.assertIn('file', folder2.objectIds())

def test_move_cant_read_source(self):
folder1, folder2 = self._initFolders()
Expand Down
20 changes: 12 additions & 8 deletions src/OFS/tests/testFileAndImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,16 @@ def setUp(self):

# Since we do the create here, let's test the events here too
self.assertEqual(1, len(self.eventCatcher.created))
self.assertTrue(
aq_base(self.eventCatcher.created[0].object) is aq_base(self.file))
self.assertIs(
aq_base(self.eventCatcher.created[0].object),
aq_base(self.file)
)

self.assertEqual(1, len(self.eventCatcher.modified))
self.assertTrue(
aq_base(self.eventCatcher.created[0].object) is aq_base(self.file))
self.assertIs(
aq_base(self.eventCatcher.created[0].object),
aq_base(self.file)
)

self.eventCatcher.reset()

Expand Down Expand Up @@ -207,23 +211,23 @@ def testManageEditWithFileData(self):
self.assertTrue(ADummyCache.invalidated)
self.assertTrue(ADummyCache.set)
self.assertEqual(1, len(self.eventCatcher.modified))
self.assertTrue(self.eventCatcher.modified[0].object is self.file)
self.assertIs(self.eventCatcher.modified[0].object, self.file)

def testManageEditWithoutFileData(self):
self.file.manage_edit('foobar', 'text/plain')
self.assertEqual(self.file.title, 'foobar')
self.assertEqual(self.file.content_type, 'text/plain')
self.assertTrue(ADummyCache.invalidated)
self.assertEqual(1, len(self.eventCatcher.modified))
self.assertTrue(self.eventCatcher.modified[0].object is self.file)
self.assertIs(self.eventCatcher.modified[0].object, self.file)

def testManageUpload(self):
f = BytesIO(b'jammyjohnson')
self.file.manage_upload(f)
self.assertEqual(self.file.data, b'jammyjohnson')
self.assertEqual(self.file.content_type, 'application/octet-stream')
self.assertEqual(1, len(self.eventCatcher.modified))
self.assertTrue(self.eventCatcher.modified[0].object is self.file)
self.assertIs(self.eventCatcher.modified[0].object, self.file)

def testManageUploadWithoutFileData(self):
self.file.manage_upload()
Expand Down Expand Up @@ -297,7 +301,7 @@ def testPrincipiaSearchSource_text(self):
self.file.manage_edit('foobar', 'text/plain',
filedata=b'Now is the time for all good men to '
b'come to the aid of the Party.')
self.assertTrue(b'Party' in self.file.PrincipiaSearchSource())
self.assertIn(b'Party', self.file.PrincipiaSearchSource())

def test_manage_DAVget_binary(self):
self.assertEqual(self.file.manage_DAVget(), self.data)
Expand Down
Loading

0 comments on commit 50efcb0

Please sign in to comment.