On 12/04/2021 00:00, Daniele Nicolodi wrote: > On 11/04/2021 23:55, kuba....@gmail.com wrote: >> Hi Dan, >> >> Yes, I am able to reproduce the same problem using the command line if I >> invoke the csv_test.py script. > > I see it too. I'm in it. In the meanwhile: > > bin/python -m pytest beangulp/importers/csv_test.py > > works (here at least).
After thinking about it for minute: I am afraid there is no solution. The issue is that when you invoke the tests like this: python beangulp/importers/csv_test.py the directory where the scripts that is execute by the interpreter is located gets added as first entry of sys.path, thus, when the test code does: from beangulp.importers import csv Python goes to interpret benagulp/importers/csv.py which does import csv which, because of the entry in sys.path, resolves again to beangulp/importers/csv.py instead than to the standard library module. The change of sys.path is one of the main reasons why I don't make the tests modules I write work as stand alone scripts. Sometimes it gets in the way, like in this occasion, and sometimes it hides issues. Both pytest and unittest allow to easily load tests from specific modules, and I find this solution much cleaner. I think I'll be actually remove the if __name__ == '__main__': unittest.main() from this and other test modules. Cheers, Dan -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/435ee204-1946-3e17-1394-388ee0329431%40grinta.net.