unit testing - Does Python unittest report errors immediately? -
Does the unitist module of Python always report errors in the strict correspondence to the execution order of the lines to check the code? Do errors produce the possibility of unexpected changes in the code variation?
The nervous line with a major error reported by me, looks fine on its own. Before stopping the execution, the key of the request was to print the debugging and the dictionary key that was in the key dictionary was a different key referenced in KeyError but it also seemed to be in the dictionary.
I put a counter variable in the outer loop just to print the number of external iterations before the error line (inside an internal loop), and do not output to the expected sequence. They come out something like 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 2, 2, 2 - when I 0, 0, 1, 1, 1, 2 , 2, 2. and debugging the prints of internal data shows unexpected changes from one loop to another.
Code (with many debugging lines):
def onSave (screen_data): ==, flds_dct: for the counter table in self.target_tables.items () Print 'loop top' print 'field:%' print '% s'% Table print' field:% s'% flds_dct ['regions'] tbl_screen_data = {} fld for flds_dct [' regions']: Print 'fld% Screen data:% s'% screen_data print 'counter:% s'% counter print' screen data output:% s'% screen_data [fld] tbl_screen_data [fld] = screen_data [fld] print 'loop down' self.tables [ Table] .addEntry (tbl_screen_data) counter = +1 print 'bah Just before the error, this output: > tab: question field: ['whatIsYourQuest', 'whatIsYourName', ' WhatIsTheAirSpeedOfSwallow '] Loop Top Area: whatIsYourQuest Screen Data: {' whatIsYourQuest ':' grail ',' whatIsYourName ':' arthur ',' whatIsYourFavoriteColour ':' blue ',' whatIsTheAirSpeedOfSwallow ':' African or European ',' whatIsCapitalOfAssyria? ':' Ninevee '} Counter: 1 screen data output: Gray loop bottom outer loop down
But the execution stops and I get this error message:
< Pre> line 100, 'screen data output in writeData print:% s screen_data [fld] KeyError:' whatIsCapitalOfAssyria '
but the error has been attributed to one line which is previously Since its output has been printed, and after the line with error, after the output of several lines, Stops the day.
As I mentioned above, further debugging shows that the contents of screen_data are changed to loop iterations. Importantly, there is no key in the dictionary passed 'whatIscapitalOfAssyria'.
The absence of that key was the cause of the error; At some point the code asked the screen_data dictionary 'WhatisAptalAffEsiriya', which could not answer it, and it is obvious that it was thrown off of the bridge of death, it was a mistake , Failed But it was difficult to see that when the screen_adata object in the debugging lines does the output key; And the status of the reported error is not increased until after the execution of several other lines, which inspects the local values for the error.
So how is the code code unable to handle? What am I doing wrong here? How can I use it to avoid such a thing?
EDIT: If I said that it has been tested, then many other methods were called, which triggers calls themselves, I think that all those well investigated thoroughly But the number of interconnected calls probably matters.
I think you see the error at the next stage of your loop, compared to all of you You can see the output - from plain print
to print> gt; Try changing stderr,
statements so that there is no potential suppression risk of buffering and output.
Comments
Post a Comment