def _flagsTest(self, method, item):
        """
        Test a non-silent flag modifying method.  Call the method, assert that
        the correct bytes are sent, deliver a I{FETCH} response, and assert
        that the result of the Deferred returned by the method is correct.

        @param method: The name of the method to test.
        @param item: The data item which is expected to be specified.
        """
        d = getattr(self.client, method)('3', ('\\Read', '\\Seen'), False)
        self.assertEqual(
            self.transport.value(),
            b'0001 STORE 3 ' + item + b' (\\Read \\Seen)\r\n')
        self.client.lineReceived(b'* 3 FETCH (FLAGS (\\Read \\Seen))')
        self.client.lineReceived(b'0001 OK STORE completed')
        self.assertEqual(
            self.successResultOf(d),
            {3: {'FLAGS': ['\\Read', '\\Seen']}})

        Test a non-silent flag modifying method.  Call the method, assert that
        the correct bytes are sent, deliver a I{FETCH} response, and assert
        that the result of the Deferred returned by the method is correct.

        @param method: The name of the method to test.
        @param item: The data item which is expected to be specified.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/mail/test/test_imap.py