Nose tests for ingest - do they work OOTB?

53 views
Skip to first unread message

Oon-Ee Ng

unread,
Nov 29, 2018, 12:56:25 AM11/29/18
to bean...@googlegroups.com
I've modified the utrade example in https://bitbucket.org/blais/beancount/src/4c79f94e0858/examples/ingest/office/importers/utrade/?at=default

Basically I'm using the structure recommended in 'Importing external data', so I have:-
mainfolder -> importers -> tng -> *everything here*

tng is the name of this particular importer, of course. I have an empty __init__.py, a tng.py with my implementation (analogous to utrade_csv.py, also copies the test() function from there), and a tng_test.py (copy pasted with slight modifications from utrade_csv_test.py)

When in mainfolder, I run:- nosetests -s -v importers

And I get something I can't really debug, as text_extract isn't functions I wrote, think it's autogenerated:-
======================================================================
ERROR: Extract entries from a test file and compare against expected output.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/me/Files/Code/venvs/fava/lib/python3.7/site-packages/nose/case.py", line 198, in runTest                                                                                                        
    self.test(*self.arg)
TypeError: test_extract() missing 3 required positional arguments: 'importer', 'file', and 'pytestconfig'

======================================================================

Is there something I'm missing?

Martin Blais

unread,
Nov 29, 2018, 1:18:32 AM11/29/18
to bean...@googlegroups.com
Just about to leave, but very quickly, nose support is deprecated.
Switch to pytest.


--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To post to this group, send email to bean...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/CAGQ70eukraPT2iYJx435Vj-Uk3b_59MXarjUGaAB4Jmsnxgc_w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Oon-Ee Ng

unread,
Nov 29, 2018, 4:05:51 AM11/29/18
to bean...@googlegroups.com
Thanks, that worked. I've run into a simple problem which may or may not be a bug.

If there's non python files in the same directory, they're passed to the test, but not filtered by identify(). This means if I'm writing a pdf test, for example, and have a txt file in the same directory, the tests always fail.

It may be more correct to run identify() and not run extract/file_name/file_date/file_account if that fails. That may be out of scope though.

Martin Blais

unread,
Nov 29, 2018, 9:15:57 AM11/29/18
to bean...@googlegroups.com
On Thu, Nov 29, 2018 at 4:05 AM Oon-Ee Ng <ngoone...@gmail.com> wrote:
Thanks, that worked. I've run into a simple problem which may or may not be a bug.

If there's non python files in the same directory, they're passed to the test, but not filtered by identify(). This means if I'm writing a pdf test, for example, and have a txt file in the same directory, the tests always fail.

Quick question (not disingenuous): do you really need that txt file? Can you do without?
 

It may be more correct to run identify() and not run extract/file_name/file_date/file_account if that fails. That may be out of scope though.

It's been a while, but I cleaned up all my importer code at the same time I ported to pytest, and IIRC I changed it so that it was unconditional. It seemed more predictable that way.
I can have a look.
Best is if you can send an example directory that fails for you.


 

Oon-Ee Ng

unread,
Nov 29, 2018, 12:00:46 PM11/29/18
to bean...@googlegroups.com
On Thu, Nov 29, 2018 at 10:15 PM Martin Blais <bl...@furius.ca> wrote:
On Thu, Nov 29, 2018 at 4:05 AM Oon-Ee Ng <ngoone...@gmail.com> wrote:
Thanks, that worked. I've run into a simple problem which may or may not be a bug.

If there's non python files in the same directory, they're passed to the test, but not filtered by identify(). This means if I'm writing a pdf test, for example, and have a txt file in the same directory, the tests always fail.

Quick question (not disingenuous): do you really need that txt file? Can you do without?

Yes, I can. I was just surprised with that behaviour because it does not match (in my mind) what was being tested, which was the entirety of the bean-extract logic (including identify). 

It may be more correct to run identify() and not run extract/file_name/file_date/file_account if that fails. That may be out of scope though.

It's been a while, but I cleaned up all my importer code at the same time I ported to pytest, and IIRC I changed it so that it was unconditional. It seemed more predictable that way.
I can have a look.
Best is if you can send an example directory that fails for you.

Fair enough, while it's always possible to imagine cases where someone might want to regression-test identify, I'd agree that it's probably not worth any maintenance work.
Reply all
Reply to author
Forward
0 new messages