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)
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to