diff options
author | Zearin <zearin@gonk.net> | 2011-10-07 10:35:21 -0400 |
---|---|---|
committer | Zearin <zearin@gonk.net> | 2011-10-07 10:35:21 -0400 |
commit | 07b4dc3d6991cbdc420c246e807371c97a467d1a (patch) | |
tree | 329febd532aedfcd4daf92c807e802d1535c8f88 /doxygen/man/man3/cmd2_Cmd2TestCase.3 | |
parent | 36a2424cfd8c44d9f63bb4e2d7ac69cf7bce3940 (diff) | |
parent | 04cdcb0feb369ac4c60e10ccdc139c57e8b52e62 (diff) | |
download | cmd2-master.tar.gz |
Diffstat (limited to 'doxygen/man/man3/cmd2_Cmd2TestCase.3')
-rw-r--r-- | doxygen/man/man3/cmd2_Cmd2TestCase.3 | 239 |
1 files changed, 0 insertions, 239 deletions
diff --git a/doxygen/man/man3/cmd2_Cmd2TestCase.3 b/doxygen/man/man3/cmd2_Cmd2TestCase.3 deleted file mode 100644 index 7df05d2..0000000 --- a/doxygen/man/man3/cmd2_Cmd2TestCase.3 +++ /dev/null @@ -1,239 +0,0 @@ -.TH "cmd2::Cmd2TestCase" 3 "Fri Sep 9 2011" "Cmd2" \" -*- nroff -*- -.ad l -.nh -.SH NAME -cmd2::Cmd2TestCase \- -.SH SYNOPSIS -.br -.PP -.SS "Public Member Functions" - -.in +1c -.ti -1c -.RI "def \fBfetchTranscripts\fP" -.br -.ti -1c -.RI "def \fBrunTest\fP" -.br -.ti -1c -.RI "def \fBsetUp\fP" -.br -.ti -1c -.RI "def \fBtearDown\fP" -.br -.in -1c -.SS "Public Attributes" - -.in +1c -.ti -1c -.RI "\fBcmdapp\fP" -.br -.ti -1c -.RI "\fBoutputTrap\fP" -.br -.ti -1c -.RI "\fBtranscripts\fP" -.br -.in -1c -.SS "Static Public Attributes" - -.in +1c -.ti -1c -.RI "tuple \fBanyWhitespace\fP = re\&.compile(r'\\s', re\&.DOTALL | re\&.MULTILINE)" -.br -.ti -1c -.RI "\fBCmdApp\fP = None" -.br -.ti -1c -.RI "\fBexpectationParser\fP = \fBregexPattern\fP|\fBnotRegexPattern\fP" -.br -.ti -1c -.RI "tuple \fBnotRegexPattern\fP = pyparsing\&.Word(pyparsing\&.printables)" -.br -.ti -1c -.RI "tuple \fBregexPattern\fP = pyparsing\&.QuotedString(quoteChar=r'/', escChar='\\\\', multiline=True, unquoteResults=True)" -.br -.in -1c -.SS "Private Member Functions" - -.in +1c -.ti -1c -.RI "def \fB_test_transcript\fP" -.br -.in -1c -.SH "Detailed Description" -.PP -.PP -.nf -Subclass this, setting CmdApp, to make a unittest.TestCase class - that will execute the commands in a transcript file and expect the results shown. - See example.py.fi -.PP - -.PP -Definition at line 1476 of file cmd2\&.py'\&. -.SH "Member Function Documentation" -.PP -.SS "def cmd2::Cmd2TestCase::_test_transcript (self, fname, transcript)\fC [private]\fP" -.PP -Definition at line 1506 of file cmd2\&.py'\&. -.PP -References cmdapp\&. -.PP -Referenced by runTest()\&. -.PP -.nf -1506 -1507 def _test_transcript(self, fname, transcript): -1508 lineNum = 0 -1509 finished = False -1510 line = transcript\&.next() -1511 lineNum += 1 -1512 tests_run = 0 -1513 while not finished: -1514 # Scroll forward to where actual commands begin -1515 while not line\&.startswith(self\&.cmdapp\&.prompt): -1516 try: -1517 line = transcript\&.next() -1518 except StopIteration: -1519 finished = True -1520 break -1521 lineNum += 1 -1522 command = [line[len(self\&.cmdapp\&.prompt):]] -1523 line = transcript\&.next() -1524 # Read the entirety of a multi-line command -1525 while line\&.startswith(self\&.cmdapp\&.continuation_prompt): -1526 command\&.append(line[len(self\&.cmdapp\&.continuation_prompt):]) -1527 try: -1528 line = transcript\&.next() -1529 except StopIteration: -1530 raise (StopIteration, -1531 'Transcript broke off while reading command beginning at line %d with\n%s' -1532 % (command[0])) -1533 lineNum += 1 -1534 command = ''\&.join(command) -1535 # Send the command into the application and capture the resulting output -1536 stop = self\&.cmdapp\&.onecmd_plus_hooks(command) -1537 #TODO: should act on ``stop`` -1538 result = self\&.outputTrap\&.read() -1539 # Read the expected result from transcript -1540 if line\&.startswith(self\&.cmdapp\&.prompt): -1541 message = '\nFile %s, line %d\nCommand was:\n%s\nExpected: (nothing)\nGot:\n%s\n'%\ -1542 (fname, lineNum, command, result) -1543 self\&.assert_(not(result\&.strip()), message) -1544 continue -1545 expected = [] -1546 while not line\&.startswith(self\&.cmdapp\&.prompt): -1547 expected\&.append(line) -1548 try: -1549 line = transcript\&.next() -1550 except StopIteration: -1551 finished = True -1552 break -1553 lineNum += 1 -1554 expected = ''\&.join(expected) -1555 # Compare actual result to expected -1556 message = '\nFile %s, line %d\nCommand was:\n%s\nExpected:\n%s\nGot:\n%s\n'%\ -1557 (fname, lineNum, command, expected, result) -1558 expected = self\&.expectationParser\&.transformString(expected) -1559 # checking whitespace is a pain - let's skip it -1560 expected = self\&.anyWhitespace\&.sub('', expected) -1561 result = self\&.anyWhitespace\&.sub('', result) -1562 self\&.assert_(re\&.match(expected, result, re\&.MULTILINE | re\&.DOTALL), message) - -.fi -.SS "def cmd2::Cmd2TestCase::fetchTranscripts (self)" -.PP -Definition at line 1481 of file cmd2\&.py'\&. -.PP -Referenced by setUp()\&. -.PP -.nf -1481 -1482 def fetchTranscripts(self): -1483 self\&.transcripts = {} -1484 for fileset in self\&.CmdApp\&.testfiles: -1485 for fname in glob\&.glob(fileset): -1486 tfile = open(fname) -1487 self\&.transcripts[fname] = iter(tfile\&.readlines()) -1488 tfile\&.close() -1489 if not len(self\&.transcripts): - raise (StandardError,), 'No test files found - nothing to test\&.' -.fi -.SS "def cmd2::Cmd2TestCase::runTest (self)" -.PP -Definition at line 1495 of file cmd2\&.py'\&. -.PP -References _test_transcript(), and CmdApp\&. -.PP -.nf -1495 -1496 def runTest(self): # was testall -1497 if self\&.CmdApp: -1498 its = sorted(self\&.transcripts\&.items()) -1499 for (fname, transcript) in its: - self\&._test_transcript(fname, transcript) -.fi -.SS "def cmd2::Cmd2TestCase::setUp (self)" -.PP -Definition at line 1490 of file cmd2\&.py'\&. -.PP -References CmdApp, cmdapp, fetchTranscripts(), and outputTrap\&. -.PP -.nf -1490 -1491 def setUp(self): -1492 if self\&.CmdApp: -1493 self\&.outputTrap = OutputTrap() -1494 self\&.cmdapp = self\&.CmdApp() - self\&.fetchTranscripts() -.fi -.SS "def cmd2::Cmd2TestCase::tearDown (self)" -.PP -Definition at line 1563 of file cmd2\&.py'\&. -.PP -References CmdApp\&. -.PP -.nf -1563 -1564 def tearDown(self): -1565 if self\&.CmdApp: -1566 self\&.outputTrap\&.tearDown() - -.fi -.SH "Member Data Documentation" -.PP -.SS "tuple \fBcmd2::Cmd2TestCase::anyWhitespace\fP = re\&.compile(r'\\s', re\&.DOTALL | re\&.MULTILINE)\fC [static]\fP" -.PP -Definition at line 1505 of file cmd2\&.py'\&. -.SS "\fBcmd2::Cmd2TestCase::CmdApp\fP = None\fC [static]\fP" -.PP -Definition at line 1480 of file cmd2\&.py'\&. -.PP -Referenced by runTest(), setUp(), and tearDown()\&. -.SS "\fBcmd2::Cmd2TestCase::cmdapp\fP" -.PP -Definition at line 1490 of file cmd2\&.py'\&. -.PP -Referenced by _test_transcript(), and setUp()\&. -.SS "\fBcmd2::Cmd2TestCase::expectationParser\fP = \fBregexPattern\fP|\fBnotRegexPattern\fP\fC [static]\fP" -.PP -Definition at line 1504 of file cmd2\&.py'\&. -.SS "tuple \fBcmd2::Cmd2TestCase::notRegexPattern\fP = pyparsing\&.Word(pyparsing\&.printables)\fC [static]\fP" -.PP -Definition at line 1502 of file cmd2\&.py'\&. -.SS "\fBcmd2::Cmd2TestCase::outputTrap\fP" -.PP -Definition at line 1490 of file cmd2\&.py'\&. -.PP -Referenced by setUp()\&. -.SS "tuple \fBcmd2::Cmd2TestCase::regexPattern\fP = pyparsing\&.QuotedString(quoteChar=r'/', escChar='\\\\', multiline=True, unquoteResults=True)\fC [static]\fP" -.PP -Definition at line 1500 of file cmd2\&.py'\&. -.SS "\fBcmd2::Cmd2TestCase::transcripts\fP" -.PP -Definition at line 1481 of file cmd2\&.py'\&. - -.SH "Author" -.PP -Generated automatically by Doxygen for Cmd2 from the source code'\&. |