Thanks for the quick support on this. I've tried removing the __name__ == '__main__' and while that doesn't fix the problem it does at least show that the script should not be run in isolation.
In the meantime I have found that if I debug the full set of tests then I am able to debug the tests that I am interested in. While this works it does have the following disadvantages; 1) It takes more time before you are actually debugging the code you are interested in and 2) if you are debugging a piece of code deep inside the project the breakpoints could be hit from other tests and not just the ones of interest and 3) this works by chance and given a change of execution, the failure could be exposed again. 1) is not really a problem as the tests all complete very quickly however 2) is a little annoying. It can be avoided by setting up breakpoints in the tests of interest and using them as preconditions for the actual breakpoints in the core of the project but this is fiddly to set up. In any case, I've found a way to work around this so I don't need anything to be fixed or changed right now. On Mon, 12 Apr 2021 at 04:14, Martin Blais <bl...@furius.ca> wrote: > We *could* just rename csv.py to csvimp.py > > > > On Sun, Apr 11, 2021 at 6:19 PM Daniele Nicolodi <dani...@grinta.net> > wrote: > >> 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 >> . >> > -- > You received this message because you are subscribed to a topic in the > Google Groups "Beancount" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/beancount/BVI5zn4gqbA/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > beancount+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/beancount/CAK21%2BhNbM_YbfhpCVNqrY5duv4%2BVaRCddGPhaR0aCbkO8vFxXA%40mail.gmail.com > <https://groups.google.com/d/msgid/beancount/CAK21%2BhNbM_YbfhpCVNqrY5duv4%2BVaRCddGPhaR0aCbkO8vFxXA%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- 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/CA%2BCGoMeTBxSpyEnyKhm7-kafjuxx9Fwip_cK5K52HioO%3DX%3DOWg%40mail.gmail.com.