Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #68240

unittest weirdness

Date 2014-03-11 13:58 -0700
From Ethan Furman <ethan@stoneleaf.us>
Subject unittest weirdness
Newsgroups comp.lang.python
Message-ID <mailman.8062.1394573210.18130.python-list@python.org> (permalink)

Show all headers | View raw


So I finally got enough data and enough of an understanding to write some unit tests for my code.

These aren't the first unit tests I've written, but the behavior I'm getting is baffling.

I'm using 2.7.4 and I'm testing some routines which attempt to interpret data from a flat file and create a new flat 
file for later programmatic consumption.

The weird behavior I'm getting:

   - when a test fails, I get the E or F, but no summary at the end
     (if the failure occurs in setUpClass before my tested routines
     are actually called, I get the summary; if I run a test method
     individually I get the summary)

   - I have two classes, but only one is being exercised

   - occasionally, one of my gvim windows is unceremoniously killed
    (survived only by its swap file)

I'm running the tests under sudo as the routines expect to be run that way.

Anybody have any ideas?

--
~Ethan~

--snippet of code--

from VSS.path import Path
from unittest import TestCase, main as Run
import wfbrp

class Test_wfbrp_20140225(TestCase):

     @classmethod
     def setUpClass(cls):
         cls.pp = wfbrp.PaymentProcessor(
             '.../lockbox_file',
             '.../aging_file',
             [
                 Path('month_end_1'),
                 Path('month_end_2'),
                 Path('month_end_3'),
                 ],
             )

     def test_xxx_1(self):
         p = self.pp.lockbox_payments[0]
         # affirm we have what we're expecting
         self.assertEqual(
                 (p.payer, p.ck_num, p.credit),
                 ('a customer', '010101', 10000),
                 )
         self.assertEqual(p.invoices.keys(), ['XXXXXXXXXXX'])
         self.assertEqual(p.invoices.values()[0].amount, 10000)
         # now make sure we get back what we're expecting
         np, b = self.pp._match_invoices(p)
         missing = []
         for inv_num in ('123456', '789012', '345678'):
             if inv_num not in b:
                 missing.append(inv_num)
         if missing:
             raise ValueError('invoices %r missing from batch' % missing)

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

unittest weirdness Ethan Furman <ethan@stoneleaf.us> - 2014-03-11 13:58 -0700
  Re: unittest weirdness John Gordon <gordon@panix.com> - 2014-03-11 22:13 +0000
    Re: unittest weirdness Ethan Furman <ethan@stoneleaf.us> - 2014-03-11 15:29 -0700
    Re: unittest weirdness Terry Reedy <tjreedy@udel.edu> - 2014-03-11 23:36 -0400
    Re: unittest weirdness Ethan Furman <ethan@stoneleaf.us> - 2014-03-12 03:03 -0700
      Re: unittest weirdness Roy Smith <roy@panix.com> - 2014-03-12 09:44 -0400
        Re: unittest weirdness Ethan Furman <ethan@stoneleaf.us> - 2014-03-12 08:32 -0700
          Re: unittest weirdness Roy Smith <roy@panix.com> - 2014-03-12 13:48 -0400
          Re: unittest weirdness Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-12 23:14 +0000
          Re: unittest weirdness Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-12 23:47 +0000
            Re: unittest weirdness Ethan Furman <ethan@stoneleaf.us> - 2014-03-12 17:31 -0700
        Re: unittest weirdness Terry Reedy <tjreedy@udel.edu> - 2014-03-12 22:27 -0400
  Re: unittest weirdness Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-12 23:38 +0000
    Re: unittest weirdness Ethan Furman <ethan@stoneleaf.us> - 2014-03-12 17:36 -0700

csiph-web