/usr/lib/python3/dist-packages/twisted/test
NameSizeModeActions
__pycache__/-0755rm
cert.pem.no_trailing_newline14140644editdlrm
crash_test_dummy.py5430644editdlrm
iosim.py178430644editdlrm
key.pem.no_trailing_newline17070644editdlrm
mock_win32process.py14990644editdlrm
myrebuilder1.py1580644editdlrm
myrebuilder2.py1580644editdlrm
plugin_basic.py9430644editdlrm
plugin_extra1.py4070644editdlrm
plugin_extra2.py5790644editdlrm
process_cmdline.py1620644editdlrm
process_echoer.py2140644editdlrm
process_fds.py9450644editdlrm
process_getargv.py2830644editdlrm
process_getenv.py2680644editdlrm
process_linger.py2860644editdlrm
process_reader.py1880644editdlrm
process_signal.py2140644editdlrm
process_stdinreader.py8570644editdlrm
process_tester.py10350644editdlrm
process_tty.py1300644editdlrm
process_twisted.py12060644editdlrm
proto_helpers.py286870644editdlrm
raiser.cpython-38-x86_64-linux-gnu.so238640644editdlrm
reflect_helper_IE.py610644editdlrm
reflect_helper_VE.py820644editdlrm
reflect_helper_ZDE.py470644editdlrm
server.pem44440644editdlrm
ssl_helpers.py10320644editdlrm
stdio_test_consumer.py12160644editdlrm
stdio_test_halfclose.py19380644editdlrm
stdio_test_hostpeer.py10210644editdlrm
stdio_test_lastwrite.py12060644editdlrm
stdio_test_loseconn.py15480644editdlrm
stdio_test_producer.py15070644editdlrm
stdio_test_write.py9230644editdlrm
stdio_test_writeseq.py9150644editdlrm
testutils.py53210644editdlrm
test_abstract.py34970644editdlrm
test_adbapi.py261480644editdlrm
test_amp.py1105530644editdlrm
test_application.py328160644editdlrm
test_compat.py292780644editdlrm
test_context.py15150644editdlrm
test_cooperator.py214670644editdlrm
test_defer.py1034070644editdlrm
test_defgen.py107010644editdlrm
test_dict.py14420644editdlrm
test_dirdbm.py66950644editdlrm
test_error.py85930644editdlrm
test_factories.py46370644editdlrm
test_failure.py322880644editdlrm
test_fdesc.py73710644editdlrm
test_finger.py19970644editdlrm
test_formmethod.py36450644editdlrm
test_ftp.py1303210644editdlrm
test_ftp_options.py26850644editdlrm
test_htb.py31900644editdlrm
test_ident.py70150644editdlrm
test_internet.py464220644editdlrm
test_iosim.py90600644editdlrm
test_iutils.py134450644editdlrm
test_lockfile.py155060644editdlrm
test_log.py363300644editdlrm
test_logfile.py182270644editdlrm
test_loopback.py144860644editdlrm
test_main.py25010644editdlrm
test_memcache.py251430644editdlrm
test_modules.py178880644editdlrm
test_monkey.py56370644editdlrm
test_nooldstyle.py59550644editdlrm
test_paths.py743570644editdlrm
test_pcp.py125510644editdlrm
test_persisted.py146240644editdlrm
test_plugin.py261130644editdlrm
test_policies.py334990644editdlrm
test_postfix.py42430644editdlrm
test_process.py861200644editdlrm
test_protocols.py74500644editdlrm
test_randbytes.py33570644editdlrm
test_rebuild.py84950644editdlrm
test_reflect.py260850644editdlrm
test_roots.py18120644editdlrm
test_shortcut.py19910644editdlrm
test_sip.py252840644editdlrm
test_sob.py56320644editdlrm
test_socks.py177380644editdlrm
test_ssl.py238460644editdlrm
test_sslverify.py1133220644editdlrm
test_stateful.py20210644editdlrm
test_stdio.py131560644editdlrm
test_strerror.py51830644editdlrm
test_stringtransport.py132640644editdlrm
test_strports.py17970644editdlrm
test_task.py393260644editdlrm
test_tcp.py658200644editdlrm
test_tcp_internals.py131170644editdlrm
test_text.py64560644editdlrm
test_threadable.py37380644editdlrm
test_threadpool.py222040644editdlrm
test_threads.py132680644editdlrm
test_tpfile.py16010644editdlrm
test_twistd.py742010644editdlrm
test_twisted.py111730644editdlrm
test_udp.py246760644editdlrm
test_unix.py151570644editdlrm
test_usage.py236450644editdlrm
__init__.py1030644editdlrm
Edit: /usr/lib/python3/dist-packages/twisted/test/test_text.py (6456B)
# Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Tests for L{twisted.python.text}. """ from twisted.python.compat import NativeStringIO as StringIO from twisted.trial import unittest from twisted.python import text sampleText = \ """Every attempt to employ mathematical methods in the study of chemical questions must be considered profoundly irrational and contrary to the spirit of chemistry ... If mathematical analysis should ever hold a prominent place in chemistry - an aberration which is happily almost impossible - it would occasion a rapid and widespread degeneration of that science. -- Auguste Comte, Philosophie Positive, Paris, 1838 """ class WrapTests(unittest.TestCase): """ Tests for L{text.greedyWrap}. """ def setUp(self): self.lineWidth = 72 self.sampleSplitText = sampleText.split() self.output = text.wordWrap(sampleText, self.lineWidth) def test_wordCount(self): """ Compare the number of words. """ words = [] for line in self.output: words.extend(line.split()) wordCount = len(words) sampleTextWordCount = len(self.sampleSplitText) self.assertEqual(wordCount, sampleTextWordCount) def test_wordMatch(self): """ Compare the lists of words. """ words = [] for line in self.output: words.extend(line.split()) # Using assertEqual here prints out some # rather too long lists. self.assertTrue(self.sampleSplitText == words) def test_lineLength(self): """ Check the length of the lines. """ failures = [] for line in self.output: if not len(line) <= self.lineWidth: failures.append(len(line)) if failures: self.fail("%d of %d lines were too long.\n" "%d < %s" % (len(failures), len(self.output), self.lineWidth, failures)) def test_doubleNewline(self): """ Allow paragraphs delimited by two \ns. """ sampleText = "et\n\nphone\nhome." result = text.wordWrap(sampleText, self.lineWidth) self.assertEqual(result, ["et", "", "phone home.", ""]) class LineTests(unittest.TestCase): """ Tests for L{isMultiline} and L{endsInNewline}. """ def test_isMultiline(self): """ L{text.isMultiline} returns C{True} if the string has a newline in it. """ s = 'This code\n "breaks."' m = text.isMultiline(s) self.assertTrue(m) s = 'This code does not "break."' m = text.isMultiline(s) self.assertFalse(m) def test_endsInNewline(self): """ L{text.endsInNewline} returns C{True} if the string ends in a newline. """ s = 'newline\n' m = text.endsInNewline(s) self.assertTrue(m) s = 'oldline' m = text.endsInNewline(s) self.assertFalse(m) class StringyStringTests(unittest.TestCase): """ Tests for L{text.stringyString}. """ def test_tuple(self): """ Tuple elements are displayed on separate lines. """ s = ('a', 'b') m = text.stringyString(s) self.assertEqual(m, '(a,\n b,)\n') def test_dict(self): """ Dicts elements are displayed using C{str()}. """ s = {'a': 0} m = text.stringyString(s) self.assertEqual(m, '{a: 0}') def test_list(self): """ List elements are displayed on separate lines using C{str()}. """ s = ['a', 'b'] m = text.stringyString(s) self.assertEqual(m, '[a,\n b,]\n') class SplitTests(unittest.TestCase): """ Tests for L{text.splitQuoted}. """ def test_oneWord(self): """ Splitting strings with one-word phrases. """ s = 'This code "works."' r = text.splitQuoted(s) self.assertEqual(['This', 'code', 'works.'], r) def test_multiWord(self): s = 'The "hairy monkey" likes pie.' r = text.splitQuoted(s) self.assertEqual(['The', 'hairy monkey', 'likes', 'pie.'], r) # Some of the many tests that would fail: #def test_preserveWhitespace(self): # phrase = '"MANY SPACES"' # s = 'With %s between.' % (phrase,) # r = text.splitQuoted(s) # self.assertEqual(['With', phrase, 'between.'], r) #def test_escapedSpace(self): # s = r"One\ Phrase" # r = text.splitQuoted(s) # self.assertEqual(["One Phrase"], r) class StrFileTests(unittest.TestCase): def setUp(self): self.io = StringIO("this is a test string") def tearDown(self): pass def test_1_f(self): self.assertFalse(text.strFile("x", self.io)) def test_1_1(self): self.assertTrue(text.strFile("t", self.io)) def test_1_2(self): self.assertTrue(text.strFile("h", self.io)) def test_1_3(self): self.assertTrue(text.strFile("i", self.io)) def test_1_4(self): self.assertTrue(text.strFile("s", self.io)) def test_1_5(self): self.assertTrue(text.strFile("n", self.io)) def test_1_6(self): self.assertTrue(text.strFile("g", self.io)) def test_3_1(self): self.assertTrue(text.strFile("thi", self.io)) def test_3_2(self): self.assertTrue(text.strFile("his", self.io)) def test_3_3(self): self.assertTrue(text.strFile("is ", self.io)) def test_3_4(self): self.assertTrue(text.strFile("ing", self.io)) def test_3_f(self): self.assertFalse(text.strFile("bla", self.io)) def test_large_1(self): self.assertTrue(text.strFile("this is a test", self.io)) def test_large_2(self): self.assertTrue(text.strFile("is a test string", self.io)) def test_large_f(self): self.assertFalse(text.strFile("ds jhfsa k fdas", self.io)) def test_overlarge_f(self): self.assertFalse(text.strFile( "djhsakj dhsa fkhsa s,mdbnfsauiw bndasdf hreew", self.io)) def test_self(self): self.assertTrue(text.strFile("this is a test string", self.io)) def test_insensitive(self): self.assertTrue(text.strFile("ThIs is A test STRING", self.io, False))